In 2014, four years before it became synonymous in the public imagination with the Trump administration’s “zero-tolerance” family separation policy, Southwest Key Programs applied for a permit from the city of Escondido, California, to open a children’s shelter. The wave of unaccompanied minors crossing the southern border, which President Obama that summer labeled an “actual humanitarian crisis,” was at its apex. Of the 57,000 children who crossed the border alone in the 2014 fiscal year, more than 45,000 wound up in shelters like Southwest Key. The Austin, Texas–based nonprofit had evolved into a crucial link in a migration path that stretched from the violence-ravaged neighborhoods of Guatemala, Honduras, and El Salvador to U.S. cities like Houston and Chicago where Central-American immigrants have established thriving communities.

Escondido, a wealthy conservative enclave outside San Diego, rejected the application, arguing the children’s shelter would have a “negative impact” on the community and its property values. Southwest Key sued. Big-time liberal institutions, including the ACLU and Loretta Lynch’s Department of Justice, arrived in support. Southwest Key argued the city had violated the Fair Housing Act—that denying the permit effectively caused a disparate impact based on race. (The suit would settle in 2017.) The city’s position was that the shelter was basically a detention center or a jail, and not subject to the 1968 civil rights law. Not so, the Obama administration argued: Southwest Key is a home.

In June, a similar situation played out with a different outcome. After the Trump administration’s family separation policy made international headlines, placing new demands on existing child shelters, Southwest Key announced it would lease a Houston warehouse to care for children and nursing mothers who had been apprehended by U.S. Customs and Border Protection. Houston Mayor Sylvester Turner, a Democrat, told the nonprofit to reconsider and asked the state not to license the facility, suggesting that the city might drag its feet issuing the appropriate permits. “I do not want to be an enabler in this process,” Turner said. “If we don’t speak, if we don’t say no, then these types of policies will continue.” State Sen. Sylvia Garcia, who is likely headed to Washington as a Democratic congresswoman in the fall, was more direct. “We stand here in opposition to this proposed baby jail near downtown.”

In three months, the organization had gone from a Latino-founded nonprofit that attracted Hispanic-American social workers to a “baby jail” assailed as a money-hungry player in the Trump administration’s plan to violate migrants’ human rights. How that reputation changed overnight is a story about how a nominally apolitical institution became entangled with, and compromised by, the government policies that drive its operations. It’s a case study in one of the central dilemmas of the Trump era: whether it’s possible to be a good actor in a bad system.

Founded in 1987, Southwest Key Programs initially provided services to kids caught up in the criminal justice system. It opened its first immigrant shelters nearly 20 years ago. When deteriorating conditions in Central America pushed tens of thousands of families to send their children north, the organization expanded to meet the need. Capacity grew from 500 beds in 2010 to more than 5,000 today across seven states. Kids who had crossed the border wound up spending weeks in Southwest Key facilities as they waited to be reunited with relatives living in the United States.

The Obama administration grappled with how to process the surge, ultimately deciding not to separate children from parents. Families apprehended at the border were kept in “family detention centers,” grim facilities that were criticized for various abuses. At first they were detained indefinitely, then after a 2015 court order (which Donald Trump has asked the judge to revisit), for no more than 20 days. Children who crossed alone, however, wound up in a network of shelters run by private contractors like Southwest Key. In contrast to for-profit, politically connected detention centers run by companies like CoreCivic and Geo Group, most shelters are run by nonprofit or religious groups. But sheltering children was a growth industry. In 2014, the Office of Refugee Resettlement spent nearly $1 billion on unaccompanied minors, mostly in payments to private shelter contractors.

Founded in 1987, Southwest Key Programs initially provided services to kids caught up in the criminal justice system.

Former employees at Southwest Key I spoke to described shelter work as a calling for Hispanic Americans, one marked by optimism. “At one point, it was something really positive,” recalled Jacqueline Muñoz, a social worker who worked at Southwest Key during the start of the unaccompanied minor crisis in 2013. She and others felt compelled to use their education, experience, and bilingualism at what they felt was meaningful work. A former caseworker at a Phoenix-area Southwest Key, who asked to remain anonymous, had herself been detained by Border Patrol while crossing the border with her mother two decades ago and could put herself in the shoes of children making the same trip today. The facilities drew bilingual professionals from Puerto Rico, Venezuela, Mexico, and elsewhere, and a kind of Spanish-language, pan-American culture emerged between staff and the children they were responsible for.

At that time, Southwest Key was expanding. In 2013, the nonprofit had been fêted by the National Council of La Raza at the National Latino Family Expo in New Orleans. (Founder and CEO Juan Sanchez served on the board of La Raza at the time.) The next year, as conservatives railed against Obama’s “open borders,” Southwest Key hit resistance in cities like Escondido. A far-right, anti-immigrant state representative from north of Houston pushed for a county resolution to ban the shelters. In other cities, Southwest Key battled against restrictive zoning. The organization was seen, then as now, as an enabler of the controversial policy it was reacting to.

To counter, Southwest Key often trumpeted its facilities as economic development at the local level. In 2013, when the nonprofit opened a shelter in San Benito, Texas, outside Brownsville, Mayor Joe Hernandez said the facility meant “job creation.” “That’s huge for the city,” he told the local rotary club. “There’s going to be a lot of jobs.” Other mayors spoke fondly of the organization’s role in revitalizing vacant buildings. (The flip side of this: As the number of child migrants fell from its 2014 peak, layoffs rippled across the organization. Just last year, nearly 1,000 employees lost their jobs in Cameron County, Texas, alone.)

Since the Trump administration put its zero-tolerance family separation policy into effect in May, more than 2,300 kids have been separated from their parents and distributed through the Office of Refugee Resettlement’s existing contracts to organizations like Southwest Key, which has said that 10 percent of its beds are occupied by separated children. Those kids, it’s fair to say, are the lucky ones. (The government says more than 500 kids have been reunited with parents, but independent groups have been unable to confirm that number. More than 3,000 separated children are in custody of the Department of Health and Human Services and its contractors.)

To manage the crisis it created, the federal government has also hired contractors to speed-build short-term facilities, including a barracks-style tent city in Tornillo, Texas, that appeared to represent the worst of the crisis. It was in a Customs and Border Protection facility that a civil rights attorney made the secret recording of wailing children that crystallized outrage against the family separation policy. Photos of children in chain-link fence cages were also from federal facilities.

Some private contractors have been accused of ghastly abuses. Politicians called for Texas’ Shiloh Treatment Center to be shut down as early as 2014, following allegations of physical abuse and forced drugging, and the deaths of three children in custody at Shiloh and an associated facility. Shiloh continues to work with ORR, as does Shenandoah Valley Juvenile Center, which was put under investigation by Virginia Gov. Ralph Northam last month after allegations that children were stripped, muzzled, and tied to chairs.

The record of Southwest Key, ORR’s largest contract, is not perfect. State inspectors in Texas, where the organization operates 16 facilities, have found nearly 250 “deficiencies” since late 2014, including 23 citations for “improper medical treatment”—including one case where a clinician failed to follow up for two weeks with a minor who had tested positive for an STD. The state also repeatedly criticized Southwest Key’s failure to carry out timely background checks on hires. Last year, the organization hired an employee who had been charged (though not convicted) with child pornography possession. (He was fired when the allegations came to light.)

Even former employees who had issues with Southwest Key management, however, told me they approved of the way the kids had been treated. Investigative journalists at ProPublica noted their review of records and interviews “has not unearthed the kinds of egregious abuse or neglect at Southwest Key facilities that plagues more troubled institutions.” In an op-ed that ran in several places, including the San Antonio Express-News, Sanchez defended his organization and distinguished it from detention centers and the federal officials who separated children and families.

Did Southwest Key lose its way in search of growth? The organization is taking in nearly a half-billion in federal dollars this fiscal year to manage ORR contracts. Sanchez has seen his board-determined salary climb from the low six figures in the 2000s up to $1.5 million in 2016, a very high figure even for a nonprofit with rapidly rising revenues.*

But shelters did not opt into family separation, and ORR contracts made no distinction between kids who had been separated from their parents and children who crossed alone. “We got caught off guard by it ramping up so quickly,” Sanchez told NPR. The unaccompanied minors arriving at facilities like Southwest Key were one day different from their predecessors—they had been made unaccompanied by the U.S. government. Sometimes the kids themselves were the ones to reveal that they had been separated at the border. The New York Times reported on Thursday that records linking kids and parents and been lost and in some cases destroyed.

Those kids were different. Testimonials from lawsuits filed by Washington state against the Trump administration illustrate the routine trauma of family separation. Doris Pineda, an immigrant fleeing domestic violence, was detained and separated from her 6-year-old daughter on May 22. She did not speak to her daughter, Erika Villanueva-Real, for three weeks. The day Pineda called, her daughter could not speak through tears. Nery Flores-Olivia, who was detained in Reynosa, Texas, on May 14, said on June 20 that officers told her they were taking her 6-year-old son for a shower. She had not seen him since.

The Southwest Key kids, it’s fair to say, are the lucky ones.

Religious organizations and nonprofit shelters have struggled to strike a balance between expressing their views and hewing to tightly worded ORR contracts and warnings from the agency’s political appointees. “You’re expected to support the administration in this issue,” Sanchez told the Austin Chronicle last week. (Though Southwest Key provided statements to the media during the height of the public clamor, it has largely clammed up since and referred my requests to ORR. Sanchez declined to be interviewed.) An anonymous incident commander from BCSF Health and Human Services, which built the tent city at Tornillo, Texas, in just three days to meet a federal contract, told the Texas Tribune that he hoped to never to undertake a project like this one. “It was an incredibly dumb, stupid decision,” he said of the family separation policy. Antar Davidson, a former youth care worker from a Southwest Key shelter in Arizona, told CNN he quit his job because he felt he had become complicit. In an earlier interview, he told the Los Angeles Times he had been instructed to tell children not to hug. (This is not company policy, Sanchez later told NPR, though there is a section of the manual on what kind of touching is appropriate.) Davidson noted how the atmosphere at his facility had changed since the arrival of children who had been separated from their parents by the U.S. government.

One particularly controversial issue that has escalated recently concerns pregnant minors. Last year, the ACLU estimated that several hundred pregnant minors are in federal shelters. Since Scott Lloyd, a lawyer with the Catholic charity Knights of Columbus, took the reigns at ORR in March of 2017, he has intervened to discourage minors from seeking abortions. Last spring, he made a personal call to a girl asking for an abortion at a Southwest Key shelter in Phoenix.

Lawyers say ORR’s orders to deny pregnant minors access to counsel have been dutifully carried out by shelters worried they will lose funding. In October, the D.C. Circuit Court ruled that Jane Doe, a pregnant, unaccompanied minor who had entered the country without her parents, could obtain an abortion over the objections of the Trump Administration. Five months later, International Education Services, where that Jane Doe had been held, was abruptly shut down by ORR without explanation.

Rochelle Garza, the court-appointed lawyer to that Jane Doe, told me that she’s had subsequent Jane Doe clients held in Southwest Key facilities. “I never know if I’ll actually get to see my clients. I’ve actually been physically prevented from seeing a client by SWK guards. I’ve also been told “She doesn’t want to see an attorney. Try another day,” Garza said. “It’s hard to tell who this is coming from—Southwest Key or ORR—but the same problem persists and that’s access to counsel.” That incident occurred in February, she said. She did not see the client again. A source at the shelter told me that approval process is determined by ORR.*

Southwest Key released a statement announcing its opposition to the family separation policy, though only after the Trump administration suspended it in response to public outrage. But Sanchez has not expressed regrets for taking in separated kids. Where Houston’s Mayor Turner saw complicity, he saw an obligation. “If we don’t take care of them, who’s going to take care of them?” he said in an interview with a Houston television station. “They’re going to wind up in a detention center, a real detention center, and other facilities that are not adequate for children.”

That was not an abstract question. Every former Southwest Key employee I spoke to was personally against the Trump administration’s family separation policy. But once kids had been separated from their parents, they suggested—as Sanchez had—wouldn’t it be better for them to wind up in reputable, clean, safe facilities? Facilities once acclaimed as a model by the Inter-American Commission on Human Rights and the United Nations Human Rights Council?

“I know people keep saying it’s like a jail because they had a strict schedule,” said Yazmin Torres, who worked a handful of jobs at a Southwest Key shelter in Glendale, Arizona. “But it was a routine, and they needed it. That routine gave them a sense of security. I would describe it like a summer camp”—a term Laura Ingraham had used less earnestly—“[with] lessons, school routines, sleeping with all your friends. When it was time for the kids to leave, they’d make each other bracelets, say, ‘I’ll find you on Facebook.’ ”

Employees told me that yes, the nonprofit had its share of problems and growing pains, but that the way it is perceived now has less to do with its expansion and more with how the family separation policy upended the purpose of the work.

Southwest Key’s reputation for running a tight ship has made it, ironically, a showcase venue for a policy decried as a human rights violation. One facility in Phoenix has embodied the paradox. The publicity-friendly lawyer Michael Avenatti, representing separated children, visited in late June to spotlight the Trump administration’s cruel policies. He also told the Arizona Republic that the facility was “well-maintained,” and the staff “cooperative” and “doing their best.” A week later, the same location was the site for a redemptive visit by Melania Trump, whose first display of concern at the border was eclipsed by a jacket that read “I really don’t care, do u?”

The important thing to remember, Torres said—and one that allowed her to brush off conflicts with supervisors and other workplace annoyances—was that virtually every kid who came through her facility left for a reunification, sometimes with parents who had arrived in the U.S. years earlier. “Some of them hadn’t seen their parents in six years,” she recalled. “Some of them were like, ‘I don’t remember what [my mom] looks like.’ ”

The Southwest Key that existed prior to this spring was a place that, even critics admit, functioned as an imperfect but well-intentioned haven for kids who had been—at the very least—on a perilous, lonely journey of more than a thousand miles to flee violence at home. For many of them, Southwest Key was a temporary refuge that preceded something their parents had spent thousands of dollars to secure: reunification with a family member in the United States. Today, for more than 3,000 kids, the joy of a promised reunion has been replaced by the trauma of indefinite separation. No caseworker can make up for that.

*Update, July 6, 2018, 9:15 p.m.: This piece has been updated with additional information since it was originally published.

*Correction, August 16, 2018: This piece initially misidentified Juan Sanchez’s 2016 salary as his 2017 salary. It has been corrected.