Shortly after his inauguration in 2009, President Obama invited Republican leaders in Congress to a White House meeting. The House members brought a proposal with ideas for stimulating the economy, then suffering through the Great Recession. In the meeting, Eric Cantor, then the House minority leader, suggested a small business-related tax cut. A few days later, Obama complained Republicans had decided to oppose his stimulus before he had spoken to their conference. Republicans had a reason. House Democrats had already drafted the bill without consulting them. Every GOP idea had been left out.

This was Obama’s first mistake. At the time, Republicans were ripe for the picking. They had lost both the House and Senate in 2006 and the presidency in 2008. They were terrified. A concession or two—even small ones—would have gone a long way toward gaining their votes. And Republicans would inherit part ownership of the stimulus package. No concessions were offered. Every House Republican voted against the bill, as did all but three in the Senate.

Then came Obamacare and the second mistake. The president and Democrats were in a hurry. They didn’t have the time or the inclination to seek Republican support. Instead, the health care bill was put together, in secret, in the office of then-majority leader Harry Reid. No Republicans were invited to the drafting party and none voted for it. Democrats became sole proprietors of Obamacare.

The third mistake was the handling of Dodd-Frank, which increased regulation of financial markets. Republicans were interested. And Democrat Max Baucus, then chairman of the Senate Finance Committee and now ambassador to China, was negotiating with Republican Bob Corker on a bipartisan bill. But Obama and liberal Democrats feared Baucus was conceding too much. So the measure was snatched from the committee and written without Republican input. Just four GOP senators and three House members voted for it.

Mistakes one, two, and three were the beginning of a disaster for Obama. He and his party have an explanation for blowing off Republicans. In 2009 and 2010, they had large majorities in both chambers and didn’t need GOP votes. So why compromise? They could pass exactly what they wanted without adulterating their signature initiatives with Republican ingredients.

Politically speaking, this approach was justified. But there’s a rub—a very big rub. There happens to be great value in compromise and bipartisanship. On most legislation, those features don’t matter. On big matters that involve the entire country and affect most Americans, they are critical. They act like a seal of national approval. When both parties agree, controversial measures are no longer in serious dispute. When one party insists on having its way, controversy lingers.

Obamacare is a prime example of what can occur, Dodd-Frank less so (and the stimulus has expired). As a product of bipartisan compromise, it would be, at worst, less unpopular than it is now. But as wholly owned property of the president and Democrats, forced on an unwilling public, it’s loathed. For Democratic candidates, it’s an albatross. It was partly responsible for the defeat of two ex-senators, Russ Feingold in Wisconsin and Evan Bayh in Indiana, who were seeking to return to the Senate. Having once voted for Obamacare caught up with them on November 8.

As bad as Obama’s relations were with Republicans in his first two years, he’s managed to make them worse since then. He’s benefited not at all from this. In 2011, he and House speaker John Boehner agreed to a $4 trillion deal of spending cuts and tax hikes—the so-called grand bargain. But the agreement unraveled when Obama insisted on hundreds of billions more in tax revenue. At that point, Boehner pulled out, saying he couldn’t trust Obama to honor a deal. Obama threw away a breakthrough that would have enhanced his presidency. Another mistake.

Thus ended Obama’s efforts, minimal though they were, to get along with Republicans in Congress. Reelected in 2012, he announced he would use his pen and the phone to handle Congress. He mainly used the pen. Rather than negotiate with Republicans, he turned to executive orders and memoranda. No need to compromise on those. He routinely exceeded his constitutional authority. He issued presidential orders on matters Congress was already working on and might enact. This was a fifth mistake.

On the few occasions when they met with Obama, Republicans found him impossible to deal with. “He always wanted it his way or not at all,” says House majority leader Kevin McCarthy. “He thinks we’re obstructing because we don’t agree with him.” Vice President Biden was different. He wanted to negotiate but usually wasn’t allowed to. When he asked Republicans a question about their plans at a White House session, Obama hushed him.

There’s a huge downside to the way Obama has done business: His entire legacy is now in jeopardy. Republicans intend to repeal Obamacare in January and replace it later. That won’t be easy. But executive actions can be nullified by the stroke of President Trump’s pen, and there’s every indication he will cancel most if not all of them. With that, much of the Obama legacy will be wiped away.

For Republicans, there’s a lesson in Obama’s experience. It’s a simple one: don’t spurn negotiation and compromise. In this, the filibuster may be their friend. Republicans can repeal Obamacare with 51 votes in the Senate. But they will need 60 to replace it, when Democrats unleash a filibuster. Republicans will have to find at least eight Democratic votes. The more they get, the better. A bipartisan replacement, with emphasis on free markets and patient choice, is bound to have flaws. That’s the price of compromise. But the replacement won’t be doomed to an early death like Obamacare.

When sweeping tax reform was enacted in 1986, bipartisan compromise was a given. Two Democrats, Senator Bill Bradley and Representative Dick Gephardt, saw it much as Republicans did (and still do). You kill tax preferences and special breaks and use the savings to lower tax rates. Today’s Democrats want the first half of the equation, but not the tax cuts. They prefer to spend the money. When Paul Ryan and Democratic senator Chuck Schumer sought a deal in 2015 on repatriating overseas corporate profits, they couldn’t agree on how to use the new tax revenue. Reaching even a broader reform measure will require Republicans to trust Ryan to get the best deal possible.

Infrastructure? Handing out billions to build roads, repair bridges, and upgrade ports should please everyone, right? Wrong. Trump has talked about a $1 trillion program, but Republicans in Congress are bent on spending less. It’s still true, as Obama learned, that there are no “shovel-ready” projects to fund instantly. A compromise might focus on modernizing the interstate highway system, which was laid out according to where people lived in the 1950s. There are twice as many Americans today, and they’ve clustered in new places.

Obama’s mistakes are a gift to Republicans. They know what not to do. This is as good a lesson as they could have expected, considering the source.