Yesterday a federal appeals court upheld a Minnesota program that indefinitely detains sex offenders after they have completed their prison sentences under the guise of treating them for mental illnesses invented by the state legislature. The U.S. Court of Appeals for the 8th Circuit overturned a 2015 decision in which U.S. District Judge Donovan Frank concluded that the Minnesota Sex Offender Program (MSOP) violates the due process rights of the people it imprisons. The appeals court said Frank wrongly applied “strict scrutiny” to the MSOP when he should have taken a much more deferential approach.

Frank correctly perceived that the “treatment” provided by the MSOP, which has never cured anyone in the program’s 23-year history, is a sham used to conceal a punitive purpose and justify preventive detention based on unsubstantiated fears of future crimes. He found that the Minnesota Commitment and Treatment Act (MCTA), which allows post-prison detention of “sexually dangerous persons” and offenders with “sexual psychopathic personalities,” was unconstitutional on its face and as applied to the plaintiffs because it was not narrowly tailored to advance a compelling state interest. Among other problems with the program, Frank noted that it has admitted more than 700 people but has not fully discharged anyone, does not conduct periodic assessments to verify that offenders still meet the criteria for civil confinement, does not give detainees an opportunity for timely judicial review, does not provide the “less restrictive alternatives” mentioned in the MCTA, and imposes a heavier burden on people trying to win release than it does on local prosecutors seeking to commit them.

According to the 8th Circuit, none of that matters, because all the state had to do was avow good intentions. In considering the facial challenge to Minnesota’s law, Frank thought strict scrutiny was appropriate because the MCTA impinges on a fundamental liberty interest—i.e., the right not to be locked in a cage for the rest of your life. Frank was wrong about that, the appeals court says, because the Supreme Court “has never declared that persons who pose a significant danger to themselves or others possess a fundamental liberty interest in freedom from physical restraint.”

That way of framing the issue begs the question of whether the people confined by the MSOP do in fact pose a significant danger to others. Without periodic assessments, how can the state know? Unless someone petitions for release (which requires him to show he is “no longer dangerous”), the state apparently can just assume its treatment is not accomplishing anything. As Frank observed, “there is no meaningful relationship between the treatment program and an end to indefinite detention.”

Instead of applying strict scrutiny, the appeals court says, Frank should have asked whether the MCTA passes the “rational basis” test—a highly deferential standard that all but guarantees a challenged law will be upheld. “The appropriate standard is whether MCTA bears a reasonable relationship to a legitimate government purpose,” the court says. “MCTA is facially constitutional because it is rationally related to Minnesota’s legitimate interests.”

The 8th Circuit says strict scrutiny was also inappropriate in assessing whether the MCTA is unconstitutional as applied to the plaintiffs. To prevail on that claim, the court says, the plaintiffs had to show that their confinement not only violates a fundamental right but “shocks the conscience,” which is pretty hard to do for any kind of imprisonment this side of a Nazi concentration camp. “To meet this high standard,” the 8th Circuit explains, “the alleged substantive due process violations must involve conduct ‘so severe…so disproportionate to the need presented, and…so inspired by malice or sadism rather than a merely careless or unwise excess of zeal that it amounted to a brutal and inhumane abuse of official power literally shocking to the conscience.” Since Minnesota officials mean well (or say they do), the plaintiffs cannot possibly meet this standard.

The appeals court was unimpressed by the fact that the MSOP manifestly fails to accomplish what it purports to be doing: rendering sex offenders “no longer dangerous” by treating their statutorily defined conditions. Although “the Supreme Court has recognized a substantive due process right to reasonably safe custodial conditions,” the 8th Circuit says, it has never recognized “a broader due process right to appropriate or effective or reasonable treatment of the illness or disability that triggered the patient’s involuntary confinement.”

Twenty states and the federal government have laws allowing indefinite civil commitment of certain sex offenders, and Minnesota’s program is one of the most farcical. Criticizing Frank’s decision in 2015, Minnesota Gov. Mark Dayton exposed the fallacy at the core of the MSOP. “It’s really impossible to predict whether or not [sex offenders] are at risk to reoffend,” Dayton said. “So the more protection you can give to the public, as far as I’m concerned, given their history, is entirely warranted, and that’s what this program does right now.” Yet the MCTA requires predictions about whether or not sex offenders “are at risk to reoffend”; if such predictions are “impossible,” the whole law is a crock.

It gets worse. “I don’t think any parent in Minnesota wants to subject their daughter or their son to a probability,” Dayton said. “They want to make sure their government is doing absolutely everything conceivably possible to make it 100 percent safe to walk in the park or to or from school.” So even if recidivism were predictable, Dayton would say that someone who is 99 percent guaranteed not to reoffend should nevertheless be locked up for the rest of his life. Just in case.

In light of the 8th Circuit’s decision, it looks like reform of the MSOP will have to be accomplished by legislators acting on their own initiative. But as Minneapolis Star Tribunenotes, the decision relieves the pressure imposed by Frank’s ruling, “potentially derailing long-awaited reforms.”