The trip was seen as a simple fact-finding mission for members of Congress to view conditions at the border. But within hours of their arrival in Texas to tour facilities, the visit had turned into a fiasco for US Customs and Border Protection.

If the aim of the authorities had been to paint a sanitized vision of conditions at facilities that have created negative headlines around the world, it went wrong from the start.

The Monday trip began on the same day as the not-for-profit news organization ProPublica revealed a shocking investigation into a secret Facebook group apparently made up of current and former members of CBP. In the 9,500-strong group were numerous racist, violent and sexist posts. One post encouraged officers to throw a “burrito at these bitches”. Another said: “There should be no photo ops for these scum bucket.” Yet another included a mock-up of a pornographic image of the progressive congresswoman Alexandria Ocasio-Cortez.

Ocasio-Cortez was one of more than a dozen Democrats visiting CBP facilities accused of child neglect and filthy conditions. The trip rapidly spiraled out of control as the politicians used social media to report en masse what they had found, the arguments they had had with staff and the abuse they suffered from anti-immigration protesters outside.

Ocasio-Cortez was involved with confrontations with CBP officers as she sought to find out about conditions inside and report on what she had seen and heard, including allegations that detainees had been told to drink water out of toilets.

“This is CBP on their best behavior, telling people to drink out of the toilet,” Ocasio-Cotez tweeted, adding that the staff had confiscated her phone.

In response to claims in conservative media that she had sought to intimidate CBP staff, she tweeted: “To these CBP officers saying they felt ‘threatened’ by me – They were literally discussing making a GoFundMe for an officer who attacked me on my tour.”

“CBP officers sharing memes about dead migrants and discussing violence and sexual misconduct towards members of Congress,” Ocasio-Cortez wrote in an earlier tweet. “How on earth can CBP’s culture be trusted to care for refugees humanely?”

The California congresswoman Judy Chu, another member of the delegation, echoed Ocasio-Cortez’s description of appalling conditions in another account posted to Twitter. She said conditions at the facility were “appalling and disgusting”.

The Pennsylvania congresswoman Madeleine Dean called them indicative of a “human rights crisis”.

Meanwhile, anti-immigration activists gathered outside one of the facilities, at Clint, Texas, and hurled abuse at the visiting politicians. A Muslim American congresswoman, Rashida Tlaib, was told by one heckler: “We don’t want Muslims here either.”

Trump administration officials sought to manage the crisis.

The White House counselor Kellyanne Conway characterized the entire congressional visit as staged. Conway told Fox & Friends that Ocasio-Cortez was among those who voted against a $4.6bn bipartisan humanitarian aid package signed into law on Monday.

Joaquín Castro, chairman of the Congressional Hispanic Caucus that led the delegation, called the images “vulgar, disgusting and vile”.

Castro filmed a group of Cuban women in custody sitting in sleeping bags on a concrete floor of a small cell, which had a toilet but no running water to drink from or to wash.

“Many said they had not bathed for 15 days,” Castro tweeted. “Some had been separated from children, some had been held for more than 50 days. Several complained they had not received their medications, including one for epilepsy.”

He added: “They asked us to take down their names and let everyone know they need help. They also feared retribution.”

Castro also posted about seeing a three-year-old boy with his face pressed up against the glass of a locked steel door. “He smiled big and tried to talk to us through the thick glass. His family – or another – ate Ramen on the floor a few feet away,” he said.

Faced with the public relations catastrophe, border officials moved into damage control. The inspector general of the Department of Homeland Security has said it will conduct an independent investigation into the Facebook group revealed by ProPublica.

“These posts are completely inappropriate and contrary to the honor and integrity I see – and expect – from our agents day in and day out. Any employees found to have violated our standards of conduct will be held accountable,” said the border patrol chief, Carla Provost, in a statement on Monday.