I am resending my question about the prayer. I was with co-workers in an office. A few of these co-workers came from another place that is like over an hour away. We were praying as a congregation for the Thur, but one of those co-workers who lives a bit far was leading the prayer. I thought that we were going to pray 4 units of prayer, but we only prayed 2. I did not say the Tashahhud when I heard him say salam. I immediately followed him. A person on my left side asked if I wanted to do another prayer (of 4 units as a Sunnah prayer). I said, "Sure!" I followed their lead, and my intention for praying was that of praying the Thur. Do I have to repeat this prayer or no?
All perfect praise be to Allah, the Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallahu ʻalayhi wa sallam, is His slave and Messenger.
What we understood from your question is that you prayed the Thuhr as 2 units while you were a resident because you prayed behind an imaam who was traveling and thus shortened the Thuhr to 2 units. If this is the case, then your prayer is not valid and you have to repeat it. It is impermissible for the resident to shorten the prayer if he prays behind an imaam who is traveling and shortens the prayer. The resident, in this case, is obliged to complete the prayer individually after the imaam makes Tasleem (ending the prayer with the Salaam greeting), according to the consensus of scholars. Ibn Al-Munthir said, “The scholars unanimously agreed that if the resident is being led in the prayer by a traveler (shortening the prayer) and the imaam made Tasleem after two units of prayer, the resident must complete the prayer.” [Al-Ijmaa’]
If you repeated the prayer by joining another congregation with the intention of praying the Thuhr – as we understood from the question – then this is sufficient in clearing yourself of your liability from the obligation of praying the Thuhr.
Allah knows best.
You can search for fatwa through many choices