Answered by Ustadh Tabraze Azam
Question: As salam alaykum,
Is a man’s prayer invalid if he prays in congregation yet stands in a row by himself?
Answer: Wa alaikum assalam wa rahmatullahi wa barakatuh,
I pray that this message finds you well, insha’Allah.
No, praying in a row by yourself is not invalidating. Rather, it may be disliked if there is space in the row ahead of you, but in any case, it doesn’t affect the validity of the prayer.
See also: How Should Two Persons Pray Together?
And Allah alone knows best.
Checked & Approved by Shaykh Faraz Rabbani