The U.S. Court of Appeals for the Second Circuit affirmed Tuesday that the federal government must justify the incarceration of certain immigrants subject to deportation proceedings by showing that they are either a flight risk or a danger to the community.

The decision, from a unanimous panel of the Manhattan-based appeals court, upheld a lower court’s 2019 ruling releasing an immigrant from custody after he spent more than a year in Orange County Correctional Facility while other charges were pending against him.