Elizabeth S. Fortino, Director, Mental Hygiene Legal Service, Rochester (Patrick T. Chamberlain of Counsel), for Respondent-Appellant. Letitia James, Attorney General, Albany (Frank Brady of Counsel), for Petitioner-Respondent. Appeal from an order of the Supreme Court, Oneida County (William F. Ramseier, J.), entered February 27, 2023, in a proceeding pursuant to Mental Hygiene Law article 10. The order denied the motion of respondent to dismiss the petition. It is hereby ORDERED that the order so appealed from is unanimously affirmed without costs. Memorandum: In this proceeding pursuant to Mental Hygiene Law article 10, respondent appeals from an order denying his motion to dismiss the petition seeking his civil management. According to respondent, he was not afforded the benefit of certain time credits that, if properly credited to him, would have resulted in his release prior to August 8, 2022, the day the article 10 petition was filed. Respondent contends that because he was not lawfully detained at the time, he was not a detained sex offender within the meaning of Mental Hygiene Law § 10.03 (g) (1) and was not subject to the State’s jurisdiction. We reject that contention. Even assuming, arguendo, that respondent’s imprisonment was unlawful at the time the article 10 proceeding was commenced, we conclude that Supreme Court correctly denied his motion to dismiss, because ” ‘[t]he legality of [a prisoner's] custody is irrelevant’ ” to whether the prisoner is properly considered a detained sex offender within the meaning of the statute (Matter of State of New York v. Matter, 78 AD3d 1694, 1695 [4th Dept 2010], quoting People ex rel. Joseph II. v. Superintendent of Southport Correctional Facility, 15 NY3d 126, 134 [2010], rearg denied 15 NY3d 847 [2010]; see Matter of State of New York v. Abdul A., 123 AD3d 1047, 1047-1048 [2d Dept 2014], lv denied 25 NY3d 904 [2015]).