Answered by Ustadh Sufyan Qufi
I’m taking Imam Mawsili’s Mukhtar course right now and it was mentioned that if three people are praying in a congregation, they’d stand behind the Imam, but not directly behind. Previously we prayed with two people standing behind the Imam. Do I have to repeat my prayer, or was it valid?
What you did previously which was to pray while having two people stand behind the Imam, was correct and your prayers were valid. [Shurunbulali, Nur al-Idah]
The proper way to pray in congregation when there are two men in addition to the Imam is for the two men to pray behind the Imam. One of the followers should be exactly behind the Imam, completely facing his back. The other follower should be at the right of the follower who is strictly behind the Imam. [Ibn ‘Abidin, Radd al-Muhtar]
It has been narrated, for example, that the Messenger of Allah (Allah bless him and give him peace) was joined by a second follower after having started the prayer with one follower who was standing next to him. The Messenger of Allah (Allah bless him and give him peace) placed both of them behind him as soon as they joined. [Muslim]
And Allah knows best.
[Ustadh] Sufyan Qufi
Checked and Approved by Shaykh Faraz Rabbani