The most high-profile bipartisan legislation of the Trump era turned out to be electoral poison — or at least, not a prophylactic — for the Senate Democrats who decided to support it, which could serve as a lesson for party leaders wishing to join with the president on other bills next year.

The “Crapo bill,” a bank deregulation measure co-authored by Senate Banking Committee chair Mike Crapo, R-Idaho, and several centrist Democrats, passed Congress this spring with the help of 17 members of the Senate Democratic Caucus and 33 House Democrats.

In the 10 states where Donald Trump won in 2016 and a Democratic senator stood for re-election this year, the three who opposed the Crapo bill all won a greater share of votes in their states than the seven who voted for it. Senators voting “no” averaged 54.7 percent of the vote and won by 10 percentage points, while the “yes” votes averaged 48.1 percent and lost by 1.5 points. The only Republican who lost, Dean Heller of Nevada, also voted for the Crapo bill, and fell by 5 points to Jacky Rosen, who voted against the legislation in the House.

The Crapo bill rolled back a number of elements of the Dodd-Frank Act, including, in particular, stiffer regulations on banks that have between $50 billion and $250 billion in assets. A recent proposal from the Federal Reserve, using authority granted by the Crapo bill, expands that deregulation up to banks with as much as $700 billion in assets.

Senate Democratic supporters justified their votes by casting the legislation as a tweak to benefit community banks in small towns and rural areas, despite its greatest impact occurring well up the chain. In fact, the bill has already led to accelerated consolidation and further disappearance of community banks.

In reality, the Democrats’ rationale was likely more cynical: They thought supporting the bill would unlock campaign contributions from the financial industry. And they were right.

The three Democrats on the Senate Banking Committee who co-authored the legislation — North Dakota’s Heidi Heitkamp, Indiana’s Joe Donnelly, and Montana’s Jon Tester — became the top three senators for financial industry donations in 2017, as the bill was being written. By the end of the cycle, according to the Center for Responsive Politics, the largest Senate recipients of campaign money from commercial banks were Heitkamp ($320,891), Tester ($274,944), bill supporter Claire McCaskill ($236,743), and Donnelly ($232,966). A little behind them was the Democratic Senate candidate from Arizona, Kyrsten Sinema ($173,204), who voted for the Crapo bill in the House.

The American Bankers Association ran an ad for Tester, and Americans for Prosperity, the Koch-funded group, launched a spot thanking Heitkamp for her vote. The Independent Community Bankers of America also sent mailers for Heitkamp.

By contrast, three more liberal Democrats running in Trump states — Bob Casey of Pennsylvania; Tammy Baldwin of Wisconsin; and Sherrod Brown of Ohio, ranking member of the Banking Committee — decided that it wasn’t worth increasing industry donations by deregulating the banking sector. Their own results showed them to be right.

The following chart lists the share of the total vote each Senate Democrat running in a Trump state earned in the election, based on CNN’s numbers as of November 8. Casey, Baldwin, and Brown were the biggest winners, followed by Debbie Stabenow, who ran in a state more Democratic on Tuesday than Ohio but received a smaller percentage of the vote. Heitkamp and Donnelly, two of the co-authors of the Crapo bill, lost their races, as did McCaskill; Nelson’s race is headed to a re-count.

Candidate Percentage Margin of victory Bob Casey, Pa. 55.5 +12.7 Tammy Baldwin, Wis. 55.5 +11.0 Sherrod Brown, Ohio 53.1 +6.2 Debbie Stabenow, Mich. 52.3 +6.6 Jon Tester, Mont. 50.2 +3.3 Bill Nelson, Fla. 49.9 -0.2 Joe Manchin, W.Va. 49.5 +3.2 Claire McCaskill, Mo. 45.5 -6 Heidi Heitkamp, N.D. 44.6 -10.8 Joe Donnelly, Ind. 44.5 -6.9

Heller, who was the top Republican in terms of commercial banking industry donations ($227,325), also did poorly, losing his race.

None of this is to say that the banking bill was the primary cause of defeat or sluggish performance on Election Day; there were far more important factors, from the relative conservative lean of the states, to the Brett Kavanaugh’s Supreme Court confirmation vote, to Trump’s racist fearmongering.

But the rationale for supporters was that voting for the Crapo bill would help them electorally. Not only could they tout working together on bipartisan relief for local lenders, but they could haul in campaign donations to outpace their rivals. This was the myth that was proven wrong by the results.

Casey, Baldwin, and Brown didn’t chase the banker cash, and they did fine — better, in fact, than those who did. That shows that deregulating the financial industry was unnecessary as a political tool. To quote Adam Jentleson, former deputy chief of staff to Senate Majority Leader Harry Reid, it was “One of the all-time stupidest votes. This bill had no business passing.”