Kansas cannot bar people from conducting undercover investigations on factory farms, the a federal court in Kansas ruled Wednesday.

For nearly 30 years — since 1990 — a Kansas state law made it illegal to take photographs or record video in a factory farm or slaughterhouse “with the intent to damage an enterprise conducted at the animal facility.”

The law was the earliest example of what are now called “ag-gag” laws, which criminalize undercover investigations, often by animal welfare groups, that reveal abuses on farms. Since Kansas’s law was enacted, half a dozen states have passed such laws — and more have considered it. Legislators have been forthright about their motives: They’re worried that evidence of what goes on on these farms will outrage Americans, so they want to ban it.

So far, the courts aren’t impressed. Last year, the federal court for the southern district of Iowa ruled that Iowa’s ag-gag law was unconstitutional. On Wednesday, a federal judge in Kansas agreed. “The prohibition on taking pictures at an animal facility regulates speech for First Amendment purposes,” the court concluded, dismissing arguments that prohibiting the taking of pictures did not constitute a restriction on speech.

Even worse from a constitutional standpoint, the restriction on speech is not viewpoint-neutral, the court concluded: “The law plainly targets negative views about animal facilities and therefore discriminates based on viewpoint.”

Such restrictions are rarely constitutional — subject to a high standard called “strict scrutiny,” where the government must prove that there is a compelling state interest in suppressing the speech, and that the law is necessary to preserve that interest and narrowly tailored to prohibit as little as possible. This law didn’t meet that bar. (Trespassing is of course still illegal on farms just the same as on any other private property.)

That makes Kansas the fourth state — after Utah, Idaho, and Iowa — to see their ag-gag law struck down. But laws in Alabama, North Carolina, Montana, North Dakota, and Arkansas remain standing, with new ones passed as recently at 2017 — the product of a powerful agriculture industry furious about the animal rights movement.

What ag-gag laws are trying to hide

Undercover investigations in other states give us a hint as to what the investigations now legal in Kansas might uncover.

Iowa’s ag-gag law passed shortly after the results were revealed from an undercover investigation of Sparboe Farms in 2011, by the activist group Mercy for Animals. An investigator, working for Sparboe on a traveling crew that visited eight facilities in three states, got footage of workers burning the beaks off baby chicks, throwing chickens by the neck, and leaving dead chickens to rot in cages they shared with live birds.

The footage aired on Good Morning America, 20/20, and World News Tonight With Diane Sawyer. Almost a million people watched the footage on YouTube. People were infuriated and horrified. McDonald’s, Target, and other major egg purchasers cut ties with Sparboe Farms.

But it wasn’t just Sparboe Farms. Other investigations — in Iowa and all over the country — have turned up similar atrocities elsewhere.

An investigation by Direct Action Everywhere in North Carolina found that Smithfield Farms was using gestation crates on pregnant pigs, despite claiming it had ended the practice.

This video by the Humane Society of the United States was captured in Iowa in 2010, and depicts abuses at Rose Acre Farms and Rembrandt Enterprises. It would have been illegal to film after 2012, when the state’s ag-gag law was enacted. The investigation found cages with weeks-old decomposed hen carcasses, live hens with severe infections and abscesses, and hens suffering uterine prolapses (a consequence of the strain of laying far too many eggs), including a hen whose internal organs became caught in the floor of the cage.

Importantly, these incidents are not the result of a few maliciously cruel slaughterhouse workers. They occur routinely on factory farms — they’re systemic problems.

“In virtually every instance where we’ve exposed a factory farm, they claim there is a mythical ‘humane barn’ where the animals were well treated,” Wayne Hsiung, an investigator with Direct Action Everywhere, told Vox after one such investigation. “The reality is that they must do this because the public does not have a stomach for animal torture.“

Ag-gag laws successfully keep atrocities on farms hidden

Ag-gag laws are rarely actually used to prosecute activists. But they’ve nonetheless succeeded at their mission of squelching dissent. That, the federal judge in Kansas decided, is why the Animal Legal Defense Fund, which sued the state, had standing to sue: “ALDF wishes to conduct an undercover investigation in Kansas but has refrained from doing so out of fear of criminal prosecution under the Act. If the Court finds that the Act is unconstitutional, ALDF will commence an undercover investigation in Kansas.”

ALDF is fairly typical of other animal organizations in its reluctance to defy ag-gag laws.

The organizations that arrange undercover investigations mostly avoid putting themselves at legal risk, Josh Balk, vice president of farm animal protection at the Humane Society, told me last year. “Most organizations will not go into a state to actively break a law,” which means that ag-gag laws have been effective at shielding farms from scrutiny.

One person has been arrested under an ag-gag law so far: Amy Meyer of Utah, who stood in a public thoroughfare filming the treatment of cows in a slaughterhouse visible from the road. Utah’s law shouldn’t have applied to her, as it only prohibited recordings that were made while an investigator was there on “false pretenses.” Charges were quickly dropped once the case attracted national attention. Nonetheless, the whole episode put the lie to the insistence of ag-gag proponents that the laws would only be used to charge people for extreme and outrageous behavior.

Animal advocates have responded with caution. “None of the major animal protection groups have done anything in Iowa in the last seven years,” Harvard’s Chris Green told me last year. The ag-gag laws worked. And when Iowa’s law was overturned, animal activists went back to work in the state. (Iowa has since tried another ban, but that one has been held up in court as well.)

Our nightmarish food system

Ultimately, though, ag-gag laws aren’t the real problem, they’re a symptom of it. The problem is that what goes on on our farms is so horrifying, and so unconscionable to the typical American consumer, that agribusinesses have turned to trying to hide it.

“The situation agribusiness faced was this,” Balk told me. “They tried for many years” to defend the treatment of animals in industrial farming — blaming systemic abuses on individual bad workers, claiming that their practices were good for animals. “They lost every time. They lost ballot measures, they lost their customers — fast-food chains and major grocery stores.”

That’s why there was a sudden surge of interest in banning undercover investigations of factory farms. Ag-gag laws, in other words, came about because agribusiness concluded the horrors of our food system couldn’t stand up to the light of day.

People want affordable meat. They also don’t want animals treated cruelly. Right now, the industry is trying to provide the meat and hide the cruelty. But we can do better. It’s fair to expect a food system that doesn’t have to hide its conduct from its customers — and fair to be very concerned that our current food system considered ag-gag laws a better solution.

Sign up for the Future Perfect newsletter. Twice a week, you’ll get a roundup of ideas and solutions for tackling our biggest challenges: improving public health, decreasing human and animal suffering, easing catastrophic risks, and — to put it simply — getting better at doing good.

Future Perfect is funded in part by individual contributions, grants, and sponsorships. Learn more here.