The Utah Attorney General’s Office has agreed to pay animal welfare groups $349,000 to settle a lawsuit over the state’s “ag-gag” law, according to court documents filed on Friday.

As long as it’s approved by the Utah Legislature, the $349,000 will cover attorneys’ fees and costs, court documents state. If the Legislature doesn’t fund the payment, the parties will ask a judge to rule on an appropriate amount.

The Animal Legal Defense Fund and the People for Ethical Treatment of Animals, along with Amy Meyer — the first person charged in Utah with violating the ag-gag law — filed the lawsuit in 2013.

While standing on public property, Meyer had recorded a Draper meat-packing plant and was charged with a class B misdemeanor. The charge was dropped shortly after it was filed. Meyer had filmed a sick cow being pushed with a front-loader, according to the lawsuit.

The controversial ag-gag law — passed in 2012 — prohibited unauthorized filming of agriculture operations. The law also required someone interested in filming a livestock operation to get permission from the owner, prohibited lying to gain access to the operation, and made secret recording illegal.

A federal judge, siding with animal-rights activists, struck down the “ag-gag” law in July, ruling that it violated free-speech rights.