When Nancy Pelosi chided President Trump in the Oval Office last week that he didn’t have the votes in the House to pass a government funding bill that included $5 billion for his border wall, she was probably expecting that Trump’s GOP critics, particularly those on their way out the door, would buck him.

But when House Republican leadership, backed into a corner by the White House and the Freedom Caucus, brought it to the floor Thursday night, all but eight Republicans voted in favor of a temporary spending bill that would avert a shutdown and provide Trump’s wall money. That, coupled with the 20 House Democrats who weren’t there to vote, handed Trump a victory, at least optically, and made Pelosi’s assessment incorrect.

GOP House Majority Whip Steve Scalise (R-La.) crowed about the misjudgment of Pelosi (D-Calif.), the House minority leader, and said proving her wrong gives “the president a lot more leverage.”

Several of the Republicans who voted yes are among those who have critiqued Trump’s handling of this shutdown fight and have openly supported the House taking up the clean spending bill that passed in the Senate. Many are those who lost their reelection because of voter repudiation of Trump.

Rep. Ryan Costello (R-Pa.), a moderate who decided not to run for reelection over his frustrations with the direction of the party under Trump, has been a fixture on cable news of late admonishing Trump and the far right who the president seeks to appease. And yet, Costello supported the bill.

In an interview with the Fix on Friday, Costello said he would have preferred a clean bill but that he saw his vote not as siding with Trump but simply as a way to keep the government open.

“I was not going to use my vote as a form of protest, but I’ll give my opinion on how I think he handled it which is very poorly, which has shown weakness,” he said. “It’s ham-handed.”

Costello said if he had voted against the bill, then people could have rightly accused him of voting to shut down the government.

But Democrats see it quite differently. By not bringing up the Senate’s clean spending bill, the House GOP is inviting a shutdown and bowing to Trump’s threats.

“I can certainly see that, but if I start voting because of the perception of who it empowers or who it doesn’t, you will ultimately just be voting for things based on whether it makes people look good or bad,” Costello said. “The question was, ‘will I now vote to shut down the government on the account of the fact that there was $5 billion of border wall funding?' ”

Other Republicans cited the same reasoning. Rep. Brian Fitzpatrick (R-Pa.), who won his reelection distancing himself not only from Trump but the Republican Party as a whole, said he too voted for the bill solely to keep the government funded. He said the border wall and what Trump wanted was not a factor in his calculus.

“I’m not going to get involved in the games, our most basic function is to fund the government,” he said in an interview. "We have to vote for what’s in front of us and it’s a binary choice ...you have to choose one or the other and trying to predict what the President or the Senate is going to do is an impossible analysis.

Along those same lines, Rep. Mike Coffman (R-Colo.), who lost his reelection, tweeted:

Rep. Mark Sanford (R-S.C.), who has not been shy with his denouncements of Trump and lost his reelection in part because of his rebuke of Trump, told CNN’s Manu Raju that Trump’s refusal to support a clean bill was going back on his word.

“The president completely reversed himself on that deal and now he’s going off in a different direction. That kind of back and forth is at odds with the kind of stability that our country has usually stood for,” Sanford said, according to Raju’s tweet.

But Sanford also supported the spending bill with the border money, prompting Sen. Brian Schatz (D-Hawaii) to tweet: “Elected Republicans characterizing the Presidents actions as dangerous and undemocratic and then voting with him is... you pick the adjective ... but I will just say it is frustrating.”