House Speaker Paul D. Ryan (R-Wis.), left, and Senate Majority Leader Mitch McConnell (R-Ky.), right, listen as President Trump speaks during a meeting with congressional leaders and administration officials on tax reform at the White House on Sept. 5. (Evan Vucci/AP)

The tax bill now ready for final passage represents a big bet on the part of congressional Republicans. Facing an energized Democratic base and saddled with an unpopular president, GOP lawmakers hope that completion of the tax bill will help shield them from sizable losses in next year’s elections. Are they fooling themselves?

Assuming no last-minute hitches, the tax bill as enacted and signed by President Trump would represent a significant legislative achievement for a party that has struggled all year to convert power to productivity. As a morale boost to beleaguered politicians, its value should not be underestimated. Whether it will translate politically, as they hope, is a far different question.

On Tuesday, for the second time in two months, Republicans were given a warning that the 2018 midterm elections could cost them their House and Senate majorities, despite a map that puts Democrats at a clear disadvantage.

First came Gov.-elect Ralph Northam’s relatively easy victory in Virginia. Last week produced the shocker of Democrat Doug Jones winning the special Senate election in deep-red Alabama. Republicans can console themselves by noting that Roy Moore was an extraordinarily flawed candidate, but that should not be the extent of their post-election analysis.

One question, as Republicans prepare to vote on the tax bill, is whether they are on the defensive heading into next year because of a lack of legislative achievements — or are they in trouble for other reasons? The evidence suggests it’s the latter, not the former. It will be the responsibility of Republican officials, from the president to House Speaker Paul D. Ryan (R-Wis.), Senate Majority Leader Mitch McConnell (R-Ky.) and those running next year to make a better case for themselves.

After threatening to vote "no" on the GOP tax bill, Sen. Marco Rubio (R-Fla.) and Sen. Bob Corker (R-Tenn.) pledged their support when the bill was finalized. (Jenny Starrs/The Washington Post)

Republicans will have a body of work to take to the public next year. The tax bill, which will include ending the individual mandate of the Affordable Care Act as of 2019, will allow them to tell their core supporters that they are delivering what they said they would. Tax cuts have been part of the Republican mantra for a generation and at times served the party well politically. This bill will test the potency of tax cuts in today’s economic and political environment.

Beyond that, Republicans can argue that they and the president are reversing the direction of policy from the Obama administration by slashing regulations, offering tougher enforcement of immigration laws and reshaping environment and energy policies by executive action. Additionally, they can credibly claim that they are changing the shape of the federal judiciary, from the confirmation of Neil M. Gorsuch as a Supreme Court justice to the rapid approvals of appellate and district judges.

Along with an economy that is steadily producing jobs, a stock market that keeps hitting record highs and an unemployment rate that is at a 17-year-low, that’s a decent-size package to take to the voters next fall. So why are they in such trouble?

It begins with the president. Trump has had the lowest approval rating of any first-term chief executive from the day he was sworn in. His approval today is underwater by a significant margin. The reality is that he is this unpopular despite the state of the economy. People are making overall judgments about his performance that appear divorced from their perceptions of the economy or his role in it. That bodes poorly for the GOP.

On Election Day in Virginia, Trump’s approval was at 40 percent, his disapproval 57 percent — about the national average in a state he lost to Hillary Clinton by five percentage points. On Election Day in Alabama last week, his approval was at 48 percent, his disapproval 48 percent — remarkably unimpressive in a state he won by 28 points a year ago. A Des Moines Register poll last week found Trump’s approval at 35 percent, his disapproval at 60 percent — in a state he won by nine points against Clinton. His approval rating in Iowa lags his vote percentage from 2016 by 16 points.

Over the past half-century, three presidents have faced midterm elections with unemployment rates in the range of those today: Lyndon B. Johnson in 1966, Bill Clinton in 1998 and George W. Bush in 2006. Only Clinton, who had an approval rating in the mid-60s at the time of that midterm, avoided losses, as Democrats gained a few seats that year. Johnson, whose approval rating was in the mid-40s, saw his party lose 47 House seats in 1966. Bush, with an approval rating at the time below 40 percent, saw Democrats gain 30 seats and control of the House in 2006.

President Barack Obama, of course, suffered two big midterm defeats in 2010 and 2014, with approval ratings in the low to mid-40s. The biggest came in 2010 when the unemployment rate was more than 9 percent, far higher than the Republicans will have next year.

History is an uncertain guide, especially when it comes to anything political involving Trump. He has shown that traditional metrics mean less with him than with many other politicians. But for Republicans, the president’s unpopularity could weigh heavily against their candidates next year. Because Trump remains highly popular with rank-and-file Republicans, candidates cannot risk an open break with the president. But too firm an embrace risks turning independents away, as the elections this fall have shown.

The tax bill represents a gamble in part because the public so far has judged it unfavorably. Recent polls show that not even one-third of Americans give the bill positive marks, with a majority opposed. Trump and Republican leaders say the bill provides tax cuts to most families in the middle class, but the public judges it as tipped in the direction of the wealthy. Those numbers are significantly worse than public perceptions of the Affordable Care Act at the time it was passed.

Republicans say the tax cut they are advancing will stimulate the economy even more, creating more jobs and higher wages for workers. But economic forecasts indicate minimal boost, and the Federal Reserve is likely to keep economic exuberance in check by continuing to raise interest rates as a guard against inflation. How much workers feel from the tax cut is one important indicator. Another is whether perceptions of the bill change over the next year. The Obama administration was unsuccessful in making the Affordable Care Act more popular (at least until Obama left office).

The tax bill is projected to add at least $1 trillion to the deficit over the next decade. There is talk that House Republicans could turn to overhauling entitlements next year to address criticism that the party of fiscal responsibility has abandoned its long-standing position on that issue. Trump has pledged to resist such changes. If congressional Republicans in fact pursue such changes, they can expect massive opposition from Democrats and another battle to persuade the public to go along.

The Republican Party is even less popular than the president. That’s normally the case with politically parties, and too much should not be read into that. But it was, again, striking that in Alabama last week, the Republican Party was judged slightly less favorably than the Democratic Party, despite the state’s strong GOP leaning. Alabama voters gave the Democrats a 47 percent approval, compared with 43 percent for the Republicans. In Virginia, the split was worse, with the GOP at 38 percent favorable and the Democrats at 50 percent favorable.

Democrats have plenty of problems to face in the future. In Virginia, for example, independent voters gave Democrats a negative rating, though better than Republicans. But midterm elections generally aren’t a referendum on the party out of power. That’s especially true with a president who enjoys roiling the waters as much as Trump. The tax bill is something Republicans and the president have been pointing to as their redemption since they failed to repeal Obamacare. If it does pass, as expected, they’ll have to fight to prove themselves correct.