Crammed inside a bathroom stall with a female corrections officer in the Augusta Correctional Center in Craigsville, Va., Joyce Flores handed the guard a wad of toilet paper stained with her menstrual blood.

After putting in a tampon, Flores, a dental hygienist at the prison, returned to the security area and walked through the body scanner for the third time that morning as security with the Virginia Department of Corrections (VADOC) snapped pictures of her scan with their cellphones, according to a lawsuit filed by Flores.

But yet again she couldn’t convince the warden and security officers that the article inside her vagina was a tampon and not contraband. She was placed on administrative leave that day in July 2019. Two weeks later, she was fired.

On Monday, a federal judge ruled that the sex discrimination lawsuit Flores, 48, filed against VADOC last November could proceed, rejecting the corrections department’s attempt to dismiss the suit on the basis that she did not provide enough evidence to prove she was fired because of her gender.

“But for Flores’s menstruation and use of a tampon — conditions inextricable from her sex and her childbearing capacity — she would not have been discharged,” U.S. District Judge Thomas T. Cullen, a Trump appointee representing the Western District of Virginia, wrote in his opinion this week.

The lawsuit stems from VADOC’s 2018 rule banning anyone who entered its facilities from wearing tampons, claiming its body scanners could not distinguish the difference between a tampon or menstrual cup and contraband. The news made national headlines and brought swift backlash, with many critics alleging civil rights violations. Though VADOC ultimately lifted the ban about a week later, corrections officials acknowledged to state lawmakers in 2019 that they were continuing to block women from wearing tampons at the facilities.

Flores says she ran afoul of the policy on July 17, 2019, after making the two-hour commute from her home in Henrico County, Va., to the Augusta Correctional Center. She had a heavy period that morning, she said in her lawsuit, as her body was going through perimenopause.

She arrived around 8:30 a.m. and followed normal procedure of walking through a body scanner. About two hours later, Flores realized she needed to change her tampon, but had forgotten to bring one in. Feeling rushed to get back to a waiting patient, she took out her tampon and placed some toilet paper in her underwear as a quick remedy, according to the complaint.

Minutes later, the complaint says, as Flores cleaned a patient’s teeth, VADOC Sgt. Benjamin Lokey asked her to go back to the security check at the entrance of the prison. He then instructed her to go through the body scanner again.

Soon, Lokey escorted Flores into a separate room and began interrogating her. He told her that “he believed her body scan image from her arrival in the morning (two hours earlier) contained a suspicious item in her vagina that was not present on the body scan image taken moments earlier,” the complaint says.

Flores proceeded to explain the events of that morning and offered to go into the bathroom with a female VADOC security officer and prove she was menstruating.

After the officer confirmed Flores’s claims and verified that she was not wearing a tampon, she escorted Flores back and instructed her to go through the body scan again. Yet, Cullen wrote in his opinion, VADOC officials “remained unsatisfied.”

Flores underwent several more hours of interrogation. She repeatedly explained that she was wearing a tampon in the first and third scans, but not the second, according to the complaint. Flores pleaded with VADOC to get an expert to look at the body scan and prove the item was a tampon.

Officers then brought Flores to the office of Warden John Woodson, where the questioning continued, the complaint says.

The warden informed Flores he was placing her on paid administrative leave for “suspicion of contraband,” the complaint says.

VADOC conducted a K-9 search of the medical unit and dental area, but found nothing, according to the complaint. They then requested to do the same with Flores’s car, which also resulted in no evidence.

Three days later, on July 20, 2019, Woodson called Flores and told her his supervisor had not made a decision about her employment status. Flores once again asked that they call a body-scan expert.

After two weeks of not hearing anything, Flores called the warden on July 31 for an update on her employment and to see whether they had called an expert. Woodson lost his temper, the complaint says, and told her he was firing her for “suspicion of contraband.” The complaint says the reason provided by VADOC for Flores’s dismissal was “pretext for sex discrimination.”

Lawyers from the Virginia Attorney General’s Office representing VADOC and lawyers for Flores did not immediately respond to a request for comment on the lawsuit late on Wednesday.

Flores’s lawsuit requests that VADOC pay compensatory damages in the amount of $300,000, back-pay damages with interest, attorneys fees and the reinstatement of her job or equitable compensation. It is not clear when Flores will return to court.