Republicans in Congress are cautiously optimistic about what they might achieve in 2018 with President Trump after capping a tumultuous year of infighting by coming together to pass a historic tax overhaul.

Republicans aren’t calling Trump’s unexpectedly constructive leadership during the tax debate a pivot — nor should they. The president resumed his provocative, problematic Twitter habit the moment he arrived in Florida for a holiday vacation at Mar-a-Lago.

But after months of enduring Trump’s scorn and ridicule, self-defeating attacks that helped sink the repeal Obamacare, Republicans are hopeful that the president’s team-oriented approach to tax reform signals that he is finally learning how to legislate.

“He’s gotten better and better at doing what’s necessary in order to be effective legislatively,” Senate Majority Leader Mitch McConnell, R-Ky., told the Washington Examiner during an interview just before Christmas.

McConnell, for much of the summer of 2017, was on the receiving end of Trump’s caustic tweets. The president vented about the difficulty lawmaking, scapegoating Republicans for his failure to deliver on his campaign promise to repeal and replace former President Barack Obama’s healthcare law.

Related: Mitch McConnell's tactical adjustments to pass tax reform could be GOP blueprint in 2018

McConnell acknowledged that the effort to pass the first federal tax overhaul in 31 years marked a welcome change in Trump’s relationship with Republicans on Capitol Hill from his first several months in office. The leader said the president’s shift helped lay a solid foundation for success.

“I think he’s getting the hang of it, in terms of the importance of having a working relationship with the people who are already here, ” McConnell said. “It’s one thing to go to a rally somewhere and talk about draining the swamp. But he’s in the swamp, now. If your definition of the swamp is people who’ve been elected, he’s part of it.”

Exactly how much Trump, 71, a career real estate developer and entertainer, has learned about lawmaking during his first year in elected office will be tested in the months ahead. So will the goodwill between him and congressional Republicans.

To avoid ruining the holidays with a government shutdown, Congress and the White House agreed to short, stopgap measures to maintain federal spending, continue surveillance powers, fund healthcare for underprivileged children. The legislation expires on Jan. 20, the one-year anniversary of Trump’s inauguration.

Then, there are the president's plans for an expensive infrastructure bill, plus decisions to make about whether to prevent the deportation of illegal immigrants brought to the U.S. as children by their parents, the so-called DREAMers who participated in the Obama-created Deferred Action for Childhood Arrivals program.

Disagreements between the president and congressional Republicans, and between various factions of Republicans, could explode, ending a short kumbaya moment punctuated by a White House ceremony in which Trump graciously (and unusually) praised his allies for accomplishing tax reform.

“January 19th is not going to be a fun day. The week leading up to it will be less fun,” Rep. Mark Meadows, R-N.C., chairman of the House Freedom Caucus, told reporters, anticipating the challenges that await Republicans next month.

Meadows added that he isn’t very optimistic about a smooth outcome given the difficulties Republicans face in the Senate, where the 60-vote requirement for most bills gives the Democrats veto power. The GOP will hold a 51-49 majority after Sen.-elect Doug Jones, D-Ala., takes office in January.

“Until we address that, we’re going to have gridlock,” Meadows said.

The pressure of the election year could compound the Republicans’ challenges.

Trump’s job approval rating has hovered near 40 percent for much of his presidency, and Democrats held a double-digit lead in the generic ballot asking voters which party they preferred was in charge in Congress.

The tax overhaul, the Republicans first major legislation since the president took office, was far more unpopular than popular when it he signed it into law in late December.

Couple that with Trump’s unorthodox behavior, and penchant for provocative tweets, and Republicans could lose control of their agenda on Capitol Hill — and a political message they plan to build around the economic benefits they expect voters to experience because of tax reform.

During the long holiday weekend, Trump segued from promoting tax reform to lodging complaints.

In a series of tweets, the president accused the “Fake News Media” of unfairness and inaccuracy; raised the specter of special counsel Robert Mueller’s investigation into whether he colluded with Russia during the 2016 campaign by accusing the FBI of bias; and claimed credit for Americans saying “Merry Christmas.”

“Successful outcomes can create positive momentum, but the GOP can still expect a rollercoaster of emotions from President Trump,” said a Republican strategist closely tied to the White House. “During an election year, the stakes will be much higher especially among House Republicans. They will need to keep their eye on the ball and not get distracted by the grind of the president's daily tweets.”