Two years later, after she was sent to serve her sentence at Downstate Correctional Facility in Fishkill, N.Y. (where she did receive treatment), she got a lawyer, David B. Shanies, who filed a new complaint accusing doctors at the Suffolk County jail of violating their own policy by denying his client treatment even though she had a hormone prescription from a veterans’ hospital in Manhattan. The suit filed by Mr. Shanies also claimed that county officials were responsible for Ms. Sunderland’s lack of care.

In a motion to dismiss the case, a lawyer for the county said last month that Ms. Sunderland had undergone surgery to remove a liver tumor four months before entering the jail and that doctors there had determined that her hormone treatment could be dangerous. That her own physicians disagreed, the motion said, did not mean that members of the jail’s medical staff were “unconstitutionally indifferent” to her needs.

The motion also argued that the county doctors — including Vincent Geraci, the medical director of the jail — were, as public employees, immune from being sued. It added that medical and legal opinions about gender dysphoria had changed significantly in recent years: Even if Dr. Geraci and his staff had stopped Ms. Sunderland’s treatment in 2012, that would not “rise to the level of a constitutional violation.”

But as the case went into litigation, Mr. Shanies began to study Dr. Geraci’s Facebook page and discovered several instances in which he had liked what court papers filed last week described as “anti-transgender and anti-L.G.B.T. messages.” One of them was a photo posted by a user named Trump Wall depicting a bathroom sign with a caption reading, “Men DO NOT belong in the bathrooms with girls!” Another was an article posted by the conservative commentator Allen West about a movement to boycott Target for its transgender-friendly bathroom policy. In the comment section, Mr. West had written, “It looks like we’re not the only ones who have a problem with liberals pushing their transgender bathroom agenda.”

At a deposition in April, Mr. Shanies asked Dr. Geraci about his activity on Facebook. According to a transcript, Dr. Geraci testified that he rarely spent much time looking at the articles or photographs in question and accused Mr. Shanies of trying to define him “based on the click of a button.” When Mr. Shanies asked if he did in fact think that “liberals are pushing their transgender bathroom agenda,” the doctor answered no.

At some point in the next few months, United States District Judge Joseph F. Bianco will rule on the county’s motion to dismiss the suit, deciding if Ms. Sunderland’s case can move toward trial or settlement. She is seeking damages of at least $1 million.

In an interview last week, Ms. Sunderland, who was released from prison in December, said that transitioning was hard enough, but to have done so in jail and without her hormone treatment was practically impossible.

“It was like trying to climb Mount Everest,” she said. “You get halfway to the top and someone tries to pull you back down.”