Indigent inmates with significant mental health issues are forced to remain incarcerated past their release dates because of a lack of community-based housing available from the state, according to a new class action filed Wednesday in Manhattan federal court.

The complaint alleges that the failure of two state agencies—the Office of Mental Health and the Department of Corrections and Community Supervision—have effectively, and illegally, extended the plaintiffs’ period of imprisonment by months and sometimes years because the state has not ensured that enough supportive housing is available upon release.