Democrats and Republicans in the US House of Representatives announced Thursday that they'd reached an agreement on legislation that will allow Puerto Rico to in effect declare bankruptcy and receive some relief from the onerous debts that are threatening to permanently wreck the island's economy. The legislation, if it passes, would mean that owners of Puerto Rico's debt receive less than 100 percent of what they are owed but would also save creditors from resorting to a costly and chaotic series of lawsuits in order to get their money.

Crucially, the bill does not entail the expenditure of any federal money and throws Republicans a bone in the form of exempting the island from the Obama administration's new overtime rules. But the bill is essentially a least-common-denominator compromise that grants the island some relief and creditors some certainty without capturing anyone's long-term vision of Puerto Rican renewal.

Passage seems likely in the wake of favorable commentary from House leaders on both sides of the aisle, but it's not entirely certain. Pressure groups representing distressed debt firms that have loaded up on Puerto Rican debt will likely oppose the bill and try to recover 100 percent of what they are owed.

What's this about a debt crisis in Puerto Rico?

If you're just tuning in, for years a quirk of US law created a tax subsidy for Puerto Rican debt that encouraged middle-class Americans to binge on loaning money to Puerto Rico without really realizing that's what they were doing. The Puerto Rican government took advantage of this situation by borrowing a lot of money, but didn't use the money to accomplish much that was useful in the long term.

Then, starting in 2006, Puerto Rico was hit with a series of economic misfortunes. At that point, its strong ties to the United States offered some downsides. Puerto Rico could not adjust to bad economic times with currency depreciation, but Puerto Ricans could adjust to bad times by moving to the mainland United States.

That has left Puerto Rico in a 10-year downward spiral of tax hikes, spending cuts, emigration, and higher interest rates. About a year ago, Puerto Rican Gov. Alejandro García Padilla announced that Puerto Rico was in a "death spiral" that he needs to halt, and he began saying that bondholders would not be fully paid.

A company or municipality facing this situation would declare bankruptcy, but federal bankruptcy law makes no provision for Puerto Rico to declare bankruptcy. A sovereign country facing this situation would declare a legal default on its debts, but Puerto Rico is not a sovereign nation — it's subject to US federal law. So there was no legal mechanism for Puerto Rico to discharge its debts.

The territory's government, however, asked Congress to create a legal bankruptcy process but warned that even absent one the money would not all be paid. Then, back at the beginning of May, Padilla started following through on his threats and skipping debt payments.

Hedge funds that own Puerto Rican debt have been arguing stridently against creating a bankruptcy process — characterizing it as a "bailout" — and insisting that they must be paid in full.

What does the new bill do, exactly?

The bill has two main provisions:

It creates a seven-member fiscal oversight board with members appointed by the president and congressional leaders that will have to approve Puerto Rico's future fiscal plans.

It allows the island to legally pay less than 100 percent of what is owed on old debts as part of a larger process to ensure that everyone gets something and the island's economy can continue to recover. This is what normally you would call "bankruptcy," except for whatever reason the bill doesn't use the word.

In addition, Puerto Rico will be exempt from the new federal overtime rule, and the law gives the oversight board the authority to lower Puerto Rico's minimum wage below the federal minimum wage level.

How much debt are we talking about?

Puerto Rico's total debt outstanding is about $72 billion, which is small relative to the overall United States economy but big pretty much any other way you slice it.

Two US states have more debt than that — California and New York — but Puerto Rico is much smaller, with approximately the population of San Diego County. New York and California are also richer than the average US state, whereas Puerto Rico is poorer.

Almost all US states have growing populations, but Puerto Rico's is shrinking. In October 2013, the Economist reported that "in America’s 50 states the average ratio of state debt to personal income is 3.4%," whereas the ratings agency Moody's says the comparable figure for Puerto Rico is 89 percent.

Hawaii, the most indebted US state by this measure, has a 10 percent ratio.

In other words, Puerto Rico's debts really are way out of line with what any state is financing, and there's no real precedent for paying down debts of this magnitude. There's no real precedent for refusing to pay them either, but default is by no means a crazy option.

Who lent Puerto Rico all this money?

A large share of the money was initially lent by people not so different from you or me — middle-class Americans, especially those living in higher tax states. As for what they were thinking, they probably weren't thinking much of anything in particular. They were just putting money away for retirement in municipal bond funds to diversify their portfolios.

Those funds, in turn, were invested in a diverse array of US public sector bonds. Since Puerto Rican bonds feature some unusual tax advantages, there was an unusually robust level of demand for Puerto Rican debt. Successive Puerto Rican governments responded to demand for their debt in the economically rational way — they borrowed an unusually large amount of money.

But none of this lending was driven by particular scrutiny of the details of Puerto Rico's economic situation, and when Puerto Rico's economic fortunes began to change about 10 years ago the dynamics became untenable.

The flip side of this mindless lending is that Puerto Rico failed to take real advantage of the financial windfall it provided. In theory, loads of cheap debt could have been used to finance incredibly useful public works projects and other social services that laid the foundations for enduring prosperity. But it didn't happen.

Instead, Puerto Rico seems to have mostly taken advantage of the opportunity to run a somewhat more generous welfare state than the island could really afford over the long term. Thus, when the easy money went away, the country was left with a huge pile of debts rather than a huge pile of enduringly useful infrastructure.

In more recent years, as it began to look like Puerto Rico wouldn't be able to pay its debts, holders of Puerto Rican bonds began dumping them and specialist distressed debt investors started picking them up at a discount. The hedge funds stand to win big if they can avoid bankruptcy and fully recoup the face value of the bonds, since they acquired the debt for much less than that.

Will the bill pass?

Passage seems likely. Treasury Secretary Jack Lew called it a "fair but tough bipartisan compromise," Nancy Pelosi praised it, and Senate Republican leaders have long insisted that if their House colleagues can pass a bill they are confident a similar measure will make it through the Senate.

Speaker Paul Ryan told the Wall Street Journal that the bill was "exactly where we want it" but wouldn't say if a majority of his caucus would vote for it.

Normally if Pelosi and Ryan agree, you would expect the bill to pass, and it probably will.

Things could fall apart, however, if enough conservative members defect from the bill that Ryan ends up mostly needing to rely on Democratic votes. If that happens, Democrats might try to insist on liberal priorities like giving Puerto Rico a more generous formula for federal health care spending or removing the conservative provisions on labor market regulation. And if that happens, even more Republicans might jump ship.

But Puerto Rico appears to really prefer bankruptcy relief over a disorderly default, and House Democrats, led by congressional Hispanic Caucus members, will probably not make too much trouble.

Isn't it a miracle that Congress is actually doing things?

Well, yes and no. On the one hand, we live in an era of gridlock. On the other hand, throughout 2015 we saw that Congress had started working again.

People didn't pay much attention, but the main federal statute governing K-12 education got an overhaul. So did the federal disability insurance system. A long-running dispute about federal highway funding got resolved, as did a long-running dispute about Medicare payments.

Last but by no means least, December saw a whole bunch of tax changes featuring good news for low-wage workers and a broad set of business interests. Congress even passed a law to ban microbeads in bath products to help protect the nation's fisheries.

These were all sort of boring least-common-denominator compromises that arguably failed to address fundamental issues, and that's exactly what happened on the Puerto Rico issue, too.

But this is a very meaningful change from the government-by-crisis mode that we saw in the 2011-'14 era of the high Tea Party. Members of Congress are sticking to their ideological guns, which limits what can get done given the White House's own ideological red lines, but Republican leaders are willing to buck their backbench purists and make deals to move low-key bills forward when possible.