You’re right. The Shah imprisoned Communists and Islamic Fundamentalists who were terrorists. There were groups like MKO/MEK and Islamists groups detonating bombs inside of Iran. It was Iran’s war on terror but the Carter Administration saw it as something entirely different.
And several decades before, We helped put pro Nazi supporters in charge of Iran and other malcontents to help our agenda there. There are no clean hands in the ME.