Republicans were confident and smug as they entered the White House on Wednesday to talk about a debt deal. Then Donald Trump made a shocking move.

Paul Ryan and Mitch McConnell were hoping to hold Hurricane Harvey funding hostage by demanding a debt ceiling raise that would carry through the 2018 Election. You know, so Republicans can claim to be fiscally responsible. However, Republicans have been a fractured party ever since Trump took office and it’s not clear that Republicans would have the votes for such a deal considering that many conservative lawmakers are demanding spending cuts as part of it.

In short, Republican leaders actually need a good number of Democrats to help them pass it. Not passing a debt ceiling increase would cause a government shutdown and screw over the victims of Hurricane Harvey. So Democrats put an offer on the table.

Democrats agreed to tie Harvey disaster relief funding to the debt ceiling increase but instead of an extension of 18 months that would be more difficult to pass, Democrats opted for a three-month increase that would expire in December.

Basically, it’s the kind of short term deal that Republicans often agreed to during President Obama’s tenure because they refused to give Obama and the Democrats any fiscal victories.

Now the tables have turned.

Of course, Republicans objected to the Democrats’ offer. Even Treasury Secretary Steve Mnuchin objected to it. But to the shock of everyone in the room, Trump took the deal, siding with the Democrats in the process while cutting Republicans off at the knees.

Republicans got absolutely nothing they wanted in the deal. What the Democrats offered is a straight up debt ceiling increase with no strings attached except the addition of Hurricane Harvey relief.

“We essentially came to a deal and I think the deal will be very good,” Trump said later aboard Air Force One.

“Given Republican difficulty in finding the votes for their plan, we believe this proposal offers a bipartisan path forward to ensure prompt delivery of Harvey aid as well as avoiding a default, while both sides work together to address government funding, DREAMers, and health care,” Senate Minority Leader Chuck Schumer and House Minority Leader Nancy Pelosi said in a joint statement.

Paul Ryan is upset that a deal was reached, calling it “ridiculous and disgraceful,” before complaining that the Democrats “played politics” as Texas drowns.

But Democrats simply put a deal on the table and Trump accepted it after hearing arguments from both sides. He liked the Democrats’ argument better.

Indeed, Republicans would have had a more difficult time getting their own bill passed, which could have resulted in a shutdown and a devastating delay to the aid hurricane and flooding victims desperately need right now. If Paul Ryan and Mitch McConnell really cared about not playing politics they would have immediately supported the Democrats’ plan instead of holding out for a deal that would eventually include spending cuts or endless votes on amendments that have nothing to do with the package.

Trump’s agreement on the deal does hurt the GOP, however. Hurricane Harvey relief won’t be part of the conversation in December when this new increase expires. Again, Republicans were hoping to use Harvey relief funds to get the deal they wanted, and they failed. Now they’ll have to negotiate in good faith without countless lives hanging in the balance, and if a government shutdown happens, it will be because they are incapable of governing.

This also opens the door for Democrats to work with Trump on issues they care about, especially since Trump wants Congress to act on DACA in the next six months before it officially expires. Republicans may have the majority, but Democrats appear to be the party that will be able to work with Trump on a legislative level without putting the entire country at risk. The same cannot be said of the Republicans, who have put many disastrous bills up for a vote this year, including one that would have stripped healthcare from over 20 million people.

If Trump and Democrats are able to work together, that would make Republicans more vulnerable to getting their asses handed to them in 2018 as Americans decide that Democrats are the more responsible party. Trump is desperate for legislative victories. If Democrats control Congress, he could get some victories, but they would be on the Democrats’ own terms. Democrats could persuade Trump to support their policies by making better arguments. And Republicans would left out in the cold where they belong.