Friday night was a mess for House Republicans, as party infighting nearly forced the Department of Homeland Security to shutdown.

It was also a preview of what to expect should the Supreme Court rule against Obamacare this fall. Namely, total chaos.

The debate over whether to fund the Department of Homeland Security exposed persistent fault lines that divide Republican House leadership and the rank-and-file.

Republican Leadership wanted to move forward with a clean funding bill that would keep DHS up and running. Conservatives, however, had more demands: they insisted on pairing funding with a bill that would strike down the President's executive actions on immigration, just in case courts overrule the recent ruling against that program.

Republicans managed to save face at the last minute, passing a bill to fund DHS for an additional week at 10 p.m. on Friday — two hours before the department was set to shutter.

House Republicans could have to deal with an even more vexing situation this spring, when the Supreme Court hands down its decision in King v. Burwell. That's the case where challengers argue that the Obama administration does not have the legal authority to distribute insurance subsidies on the federal marketplace.

If the Supreme Court rules in the challengers' favor, expect to see something like the DHS fracas on steroids.

Lots of options but no clear exit strategy

A decision against the health law would eliminate billions of dollars in subsidies received by Americans who bought coverage on Healthcare.gov. And Republicans, fresh off a victory of knocking a major hole in Obamacare, would face a vexing question: what now?

House Republicans haven't coalesced around one solution. They have about five options (Ramesh Ponnuru gives an especially helpful overview of those) and none of them are especially good. House Republicans could demand full repeal of Obamacare — a proposal that is dead on arrival at the White House.

They could bargain with Obama to repeal just a part of the Affordable Care Act. They might ask for the individual mandate, for example, to go. But Obama won't agree to that — any tweaks that Obama would accept are likely too small for Republicans to propose.

There are other options, too, like simply acquiescing to the White House's or building giving states an opt-out clause from Obamacare. None of these are especially likely to become law. But the additional options mean more factions, with legislators breaking off to back different approaches.

Senate Republicans are trying to get ahead of the issue; Sen. John Barrasso (R-Wyo.) is leading a working group to try and come up with possible solutions. As Byron York reported earlier this week, that group "still hasn't decided on a specific plan."

It's easy to see why: coming up with a consensus on Obamacare among Republicans is a thankless, nearly impossible task. There are conservative legislators who want full repeal, and insist nothing else will do. More pragmatic legislators tend to look for particular items to negotiate on, but those will do nothing for the full-repeal caucus. And legislators who just want to fix the law, and call it a day? It's hard to see their demands getting much traction at all.

In the DHS fight, there are two schools of thought: pass the clean funding bill, or don't. In an Obamacare fight, you could easily imagine a half-dozen or so warring proposals about what to do next.

Obamacare is a major issue for Republicans, more so than DHS

Obamacare has, for five years now, been the Republican Party's white whale. They've thrown dozens of repeal votes, countless election ads, and two Supreme Court cases at the law. None of it has worked and the president's health care law has survived largely intact.

If the Supreme Court rules against the law, that will be the first time that Republicans have succeeded at actually blowing a hole in the law. And that will near certainly mean lots of debate and fighting over what to do next. Republicans would be getting the opportunity they've hoped for since March 2010, when the President signed the Affordable Care Act into law. And that, without a doubt, would be an extraordinarily giant mess.