‘It’s bats- -t crazy,” Susan Rice said Monday on CBS’ “The Late Show with Stephen Colbert.” The former national security adviser, who served under President Barack Obama, was referring to President Trump’s decision to pull US troops from northern Syria. She was particularly dismayed by what she depicted as a dangerous betrayal of The People’s Protection Units, also known as the YPG, the Kurdish force that helped the US-led coalition ­defeat Islamic State.

“These are the people who for the last four years have been fighting on our behalf, with our equipment, to defeat ISIS,” she said. “And they have done it with enormous efficacy, and they have sacrificed immensely, and we basically just said to them, ‘See ya,’ and let the Turks, who are like the hungry wolf trying to kill the lamb, go for it.”

Over the last few days, a host of former Obama officials have been repeating this story, which is highly misleading, to say the least. Rice and her colleagues would have us believe that Team Obama created a highly effective plan for stabilizing the Middle East by working through groups like the YPG, and Trump, mercurial and impulsive, is throwing it all away by seeking a rapprochement with Ankara. That’s nonsense.

In fact, the close relationship with the YPG was a quick fix that bequeathed to Trump profound strategic dilemmas. Trump inherited from Obama a dysfunctional strategy for countering ISIS, one that ensured ever-greater turmoil in the region and placed American forces in an impossible position.

To be sure, the YPG are good fighters, and the American soldiers who have fought alongside them hold them in very high esteem. But the decision to make them the primary ally for defeating ISIS came at a hidden cost: the alienation of one of America’s closest allies. The YPG is the Syrian wing of the PKK, the Kurdish separatist group in Turkey.

Designated as a terrorist group by the State Department, the PKK has prosecuted a long war against the Turkish Republic, resulting in the death of some 40,000 people.

The Turks beseeched the Obama administration not to align with their sworn enemy, but the Obamaians told them, in effect, to sit down and shut up. Why? The American relationship with the YPG was a direct outgrowth of the greatest blunder of the Obama administration: the effort to reach a strategic accommodation with Iran.

It all began in 2014 with the siege of Kobani, a Kurdish town in Northeast Syria that was surrounded by ISIS fighters. Because the plight of the town was well-reported in the American media, Obama came under political pressure to intervene militarily to break the siege.

Until then, however, he had strenuously avoided involvement in the Syrian civil war. To be sure, he sought to avoid a quagmire, but he also was eager to avoid alienating the Iranians and the Russians.

By now, the negotiations that would lead to the Iran nuclear deal were underway. But Damascus was the close ally of both Russia and Iran, so any American intervention in Syria risked upsetting the new relationship that Obama was attempting to forge with Moscow and Tehran.

This factor is the hidden key to understanding why Team Obama gravitated to the YPG to solve its problems. The group had a long history of cordial ­relations with the Russians and the Iranians, and, best of all, it had no intention to topple the Assad regime. Every other group that Obama might have used to defeat ISIS had an anti-Assad agenda.

So, no, Trump is not betraying the YPG. He is seeking to restore balance to American foreign policy.

The YPG knew from the ­beginning that its relationship with Washington was temporary and transactional. It didn’t fight as a favor to the United States. America armed, trained, equipped and funded the YPG. We gave it strong military support, including aerial bombardment, which allowed it to vanquish all foes in its neighborhood. Thanks to this assistance, the power, influence and territorial reach of the group expanded beyond its wildest dreams. In the meantime, America also held Turkey at bay.

The YPG benefitted enormously from the effort, and the Turkish-American relationship suffered in equal measure. To paraphrase Susan Rice, this was a bats- -t crazy way to solve the ISIS challenge. If she and her Team Obama colleagues want to blame anyone for this mess, they might consider looking in the mirror.

Michael Doran is a Hudson ­Institute senior fellow. Twitter: @Doranimated