President Trump’s planned immigration meeting with Senate Republicans Thursday should be a doozy.

When Trump began tweeting Wednesday about the immigration reforms he would like to see in the aftermath of the latest terrorist attack in New York City, the newly liberated Sen. Jeff Flake, R-Ariz., practically heckled him in response.

“The terrorist came into our country through what is called the ‘Diversity Visa Lottery Program,’ a Chuck Schumer beauty,” Trump tweeted I want merit based.” He made similar comments at the Cabinet meeting, saying, “We want a merit-based program where people come into our country based on merit. And we want to get rid of chain migration.”

Flake rose to the Senate minority leader’s defense, citing a doomed immigration bill both he and the New York Democrat once supported.

“Actually, the Gang of 8, including [Schumer], did away with the Diversity Visa Program as part of broader reforms,” Flake retorted. “I know, I was there.”

Trump fired his next salvo. “We are fighting hard for Merit Based immigration, no more Democrat Lottery Systems,” he tweeted. “We must get MUCH tougher (and smarter).”

Then Flake returned fire. “In fact, had the Senate Gang of 8 bill passed the House, it would have ended the Visa Lottery Program AND increased merit based visas,” he shot back.

The junior senator from Arizona has acknowledged his approach to immigration has lost favor with Republican primary voters. Membership in the Gang of Eight was also the single biggest obstacle to Sen. Marco Rubio, R-Fla., gaining traction in last year’s GOP presidential primaries, surpassing even his unfortunate debate exchange with New Jersey Gov. Chris Christie.

But an expansive immigration policy remains popular with some Republican senators, as it has been since Flake’s fellow Arizonan John McCain was working on the issue with then Sen. Ted Kennedy, D-Mass., under former President George W. Bush over a decade ago. Plenty still think this mix of mass legalization and border security should be the starting point of any immigration debate.

To say that immigration hawks simply refused to take yes for an answer is to misunderstand the debate inside GOP circles.

On the one side, you have Republicans who believe the problem is illegal immigration, driven wholly or in part by legal immigration caps being too low for labor market demands. On the other, there are Republicans who believe too much of our immigration is self-selected rather than matched with the needs of the U.S., with legal immigration mostly the result of family reunification and high rates of illegal immigration.

The latter camp believes that the number of immigrants admitted is of critical importance and is at present too high. And their take on paths to citizenship or even earned legal status is profoundly shaped by the experience of 1986, when legalization came first and promised — even legally mandated enforcement — came fitfully, if at all.

In the Senate, the first group of Republicans has dominated for the better part of the last decade (though even in 2013, the Gang of Eight passed legislation with minority GOP support while Democrats were unanimously for it) while the second has held sway in the House. This divide has prevented any immigration deal from taking hold, even inside the Republican Party alone.

This time, immigration hawks have powerful voices of their own inside the Senate, such as Arkansas Republican Tom Cotton and Georgia Republican David Perdue. And for the first time in recent memory, they have allies in the White House — Attorney General Jeff Sessions, various former Sessions aides throughout the administration and, to a certain extent, Trump himself.

Can Republicans arrive at a consensus now? Flake-style Republicans say they have made concessions on the diversity visa lottery, merit-based immigration, and border security only to hit a wall — no pun intended — on legalization.

Yet some of the strictest immigration restrictionists are offering concessions this time around on legalization by favoring legal status — and in Cotton’s case, an eventual path to citizenship — for those protected by Deferred Action for Childhood Arrivals. But they want to offset some of the incentives this creates for future illegal immigration and to avoid a big increase in immigration or guest workers, neither of which were really on the table during Gang of Eight.

It all sounds so simple, but it really would take The Art of the Deal to resolve. Trump will need to succeed where the Gang of Eight failed.