How do Shiites pray behind the Sunni Imam?
Following the Sunnis is permissible in order to observe unity, and praying with them is correct and separate, but takf is not obligatory and is not permissible, unless it is necessary. (1)
There is nothing wrong with participating in the congregational prayers of the Sunnis and following them, and it has been reported in some authoritative news that whoever participates in the first row of their prayers is like one who prayed in the first row behind the Messenger of God (pbuh). 2]
But if possible, he should pray in the form of Shiites, and if there is no taqiyyah, he should pray in the form of Sunnis, he should repeat it.
Of course, some authorities  believe that if there are no conditions for taqiyyah, he should absolutely repeat the prayer.
. (On the authority of the servant of God, peace be upon him) he said: Whoever prayed with them in the first row, he was the one who prayed without the Messenger of God; Klini, Muhammad ibn Ya`qub, Al-Kafi, vol. 3, p.
. Ayatollah Safi Golpayegani.