If a detainee is a lawful permanent resident who overstayed their visa or who otherwise entered the U.S. legally, they may be subject to mandatory detention if they were previously convicted of any aggravated felony, a crime involving firearms or controlled substances, or any two Crimes Involving Moral Turpitude. The standards are even stricter for LPRs returning from a trip abroad, people seeking legal admission, or undocumented immigrants. Drug trafficking, domestic violence, and prostitution convictions would be additional grounds for mandatory detention, as would any single Crime Involving Moral Turpitude or two or more convictions of any kind resulting collectively in at least five years of imprisonment.
An immigration lawyer could help a detainee or their family member explore their options for contesting mandatory detention in their particular situation. They could also help file a grievance against ICE regarding any mistreatment a detainee experience while incarcerated.