You could argue that losing your reputation is an occupational hazard of working in the Trump administration: When the president thinks you’ve lost your value, he unceremoniously tosses you aside.

That seems to be what happened to Homeland Security Secretary Kirstjen Nielsen. She was forced to step down after a meeting with President Trump this weekend, The Washington Post and others report.

Even by Trump administration standards, where being fired by tweet is the norm, Nielsen’s forced resignation this weekend was particularly egregious. And it underscores just how anxious the president is about whether he has done enough to deliver on his hard-line immigration policies ahead of 2020.

Nielsen is the person in Trump’s Cabinet charged with carrying out his hard-line immigration policies. Even though behind the scenes Nielsen had reportedly fought Trump’s most controversial ideas, like separating migrant families at the border, she also went out of her way to publicly defend even the most extreme, often resorting to factually dishonest arguments that earned her public ridicule.

As The Fix’s Aaron Blake has chronicled, Nielsen has blatantly contradicted or ignored findings by the State Department, the U.S. intelligence community and her own agency to toe the president’s line on a number of issues:

— Her agency’s policy of separating migrant children from their parents at the border. She once argued “we do not have a policy of separating families at the border, period,” even though it was her agency’s interpretation of existing law that separated the families. Trump implicitly acknowledged as much when he abruptly ended it, shortly after Nielsen tweeted that.

— Whether border crossings rise to a national emergency. When Trump went around Congress and declared a national emergency at the border to build his wall earlier this year, Nielsen had to go before lawmakers and defend that legally questionable move. But she was undercut by her boss when Trump said he didn’t have to declare this emergency.

— Trump’s worldview on race. She refused to confirm whether Trump called Haiti, El Salvador and African nations “shithole countries,” even though she was present at the meeting where it happened. Then, when asked by members of Congress why Trump said he wanted more immigrants from Norway instead of these majority-minority countries, she feigned ignorance that Norway is a mostly white country so as to avoid having to talk about the undeniable racial component of Trump’s comments.

— Whether terrorists are crossing the border. During the government shutdown fight over the border this year, Nielsen more than any other Trump official insisted on repeating a falsehood that terrorists have crossed the U.S.-Mexico border. The State Department has said there’s “no credible evidence” that terrorists are in Mexico trying to cross the border, let alone have made it across.

— Basic facts about Russian election interference. She has said she didn’t know if Russia interfered in the 2016 president election to help Trump win, despite a thorough intelligence report declaring as much. “That the specific intent was to help President Trump win? I’m not aware of that,” she said as recently as summer of 2018, more than two years after the report was released to the public.

As we said, embarrassment and public ridicule are part of the job of being a Trump administration official. Trump bashed his former attorney general, Jeff Sessions, publicly on Twitter, so much so that Republicans in Congress urged him to stop.

But the thanklessness of Nielsen’s job was particularly notable, and the extent to which Nielsen stuck her neck out for Trump was eyebrow-raising in Washington. She’s a former Bush administration official who had little-to-no immigration extremism in her background before this job. Post reporting suggests that Trump and senior adviser Stephen Miller wanted her and an official nominated to lead the Immigration and Customs Enforcement agency out because they weren’t tough enough.

What gets tougher than separating children from their parents at the border, or firing tear gas at a crowd attempting to break through a border fence? Good question.

That there’s no obvious answer underscores how concerned the president may be about his immigration record right now. The president has been frustrated at the surge of migrants crossing the border despite his promise to supporters to close the entire border. Not to mention that nearly three years into his presidency, there is no wall, and there may never be. He lost the standoff with Congress over funding it, and he’s in danger of losing a similar battle in the courts. He is in the politically tricky territory of having to campaign in 2020 to fix problems that he campaigned in 2016 to fix, note The Post’s Ashley Parker and Toluse Olorunnipa.

Nielsen’s abrupt, embarrassing and ignominious end as Trump’s top immigration enforcer appears to be a byproduct of the president’s anxiety. But in stretching the facts repeatedly to keep her job, she did little to help her reputation.