SACRAMENTO, Calif. (AP) — Gay rights advocates said Monday that they will seek to challenge an appeals court decision tossing out part of a California law designed to prxotect older LGBTQ residents in nursing homes.

The 2017 law is intended to protect against discrimination or mistreatment based on residents’ sexual orientation or gender identity.

READ MORE: Gavin Newsom On East Coast Talking About His New Children’s Book About Dealing With Dyslexia

The Third District Court of Appeal overturned the part of the law barring employees of long-term care facilities from willfully and repeatedly using anything other than residents’ preferred names and pronouns.

That ban violates employees’ rights to free speech, the court ruled Friday.

“The law compels long-term care facility staff to alter the message they would prefer to convey,” the court reasoned, adding that the ban “burdens speech more than is required” to reach the state’s objective of eliminating discrimination including harassment on the basis of sex.

Referring to residents other than by their preferred gender “may be disrespectful, discourteous, and insulting,” Associate Justice Elena Duarte wrote on behalf of the three-judge panel. But it can also be a way “to express an ideological disagreement with another person’s expressed gender identity.”

“The pronoun provision at issue here tests the limits of the government’s authority to restrict pure speech that, while potentially offensive or harassing to the listener, does not necessarily create a hostile environment,” she wrote, adding italics to “potentially” and “necessarily.”

Democratic Sen. Scott Wiener, who carried the law, said deliberately using the wrong name or pronoun is “straight up harassment” and “erases an individual’s fundamental humanity.”

READ MORE: Witness Describes I-5 Shooting That Left Man With Life-Threatening Injuries In Sacramento

Rick Chavez Zbur, executive director of Equality California, which bills itself as the nation’s largest statewide LGBTQ+ civil rights organization, said using the wrong name and pronoun is “a hateful act that denies someone their dignity and truth” and can cause depression and even suicides.

Both said they will fight the ruling, without being specific on what that would mean.

That is a decision for the state attorney general’s office, which defended the law in court, said Equality California spokesman Joshua Stickney.

The attorney general’s office said it is reviewing the decision and considering its next steps.

The appeals court upheld a second challenged portion of the law prohibiting facilities or employees from assigning rooms based on anything other than a transgender resident’s gender identity.

A Sacramento County judge had previously thrown out both parts of the lawsuit.

The law was challenged by Taking Offense, described in the decision as an “unincorporated association which includes at least one California citizen and taxpayer who has paid taxes to the state within the last year.”

MORE NEWS: Sheriff: Man Arrested After Barricading Self Inside Vehicle In Stockton

The plaintiff’s attorney, David Llewellyn Jr., did not respond to telephone and email messages.