Former Fox News host Bill O’Reilly said Thursday that President Donald Trump is undermining his own agenda by tweeting insults at lesser media figures such as MSNBC’s Joe Scarborough and Mika Brzezinski.

The president lashed out at the “Morning Joe” co-hosts Thursday in a pair of tweets in which he ridiculed the ratings of their MSNBC program, hit Brzezinski’s IQ and called Scarborough a “psycho.” He also tweeted that the couple came to his Mar-a-Lago resort in Florida on New Year’s Eve but that he would not meet with them.

O’Reilly, who for years was the highest-rated cable news host, said on “The Laura Ingraham Show” that Trump would do his presidency more good by tweeting about issues like Thursday’s vote in the House of Representatives on a pair of immigration bills.

“It’s kind of discouraging for Americans who want important things to get done to be sidetracked by something like this,” he said.

O’Reilly said Trump’s natural instinct — and his practice throughout his business career — is to hit back whenever someone criticizes him.

“But the problem is that he’s president now,” he added. “And when he does it, it gives the progressive Left, you know, a chance to eye-roll, roll their eyes. ‘Oh, here he goes again,’ and, ‘He’s not disciplined enough to be president.'”

O’Reilly is far from the first observer to argue that Trump creates self-inflicted political — and potentially legal — wounds with his Twitter habits.

O’Reilly said Trump still has “a little bit of maturing to do in office.” He said Trump should be zeroing in on the vote on “Kate’s Law,” which would increase penalties on illegal immigrants who return repeatedly to the United States. He said Trump should celebrate its likely passage and call out representatives who vote against it.