suppose a person stand behind the row though there is a sufficient gap for a man in the row. now as a latecomer should i stand beside that person so that his prayer remain valid as it is reported in the hadith that who stand behind the row alone his prayer is invalid? or should i fill the gap of the row? again if he stand alone behind row from 1st rakah and i come in 3rd rakah should i stand beside him? as his salah is already invalid according to the strong view of the scholars and i am also alone behind the row then.
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 is His slave and Messenger.
You should know that the scholars differed in opinion about the validity of the prayer of the person who prays individually behind the row (during the congregational prayer); the majority of the scholars are of the view that it is valid while the Hanbali School is of the view that it is invalid.
Shaykh Ibn Taymiyyah provided some details about it, he is of the view that if the person was excused and did not find a gap in the row (and was therefore, forced to pray alone), then his prayer is valid, otherwise his prayer is invalid. This is a sound detailing of the issue. As far as you are concerned, you can imitate the view of the scholar the knowledge and piety of whom you trust.
As for the first issue in your question, if you arrive at the beginning of the prayer, and you find a person praying alone behind the row while there is a gap in the row, then you may fill the gap and you are not sinful for this because the negligence is on the part of the one who prayed behind the row. However, you may also stand alongside with him if you choose to do so.
It appears from the words of Shaykh Ibn 'Uthaymeen that he is of the opinion that one should fill the gap in the row in this case.
He said: "Whoever finds a gap, he fills it; the gap is a defect in the row, i.e., a place where there is no one. He fills it: means he is obliged to fill it if there is no one else with whom he can stand together in a row; if the one who is behind the row is alone, then they should stand together behind the row. However, if there are two or more in the last row, then he should fill that gap. If he finds a gap and there is someone who prepared himself to fill it, then what appears from the statement of the author is that the person fills it, as the negligence is on the part of the one who failed to fill it. This happens a lot; you come and find a gap in the first row [the row in front of you], and there is behind it a person who is performing an optional prayer behind the gap, and him performing an optional prayer behind the row necessitates that he is prepared to fill the gap, so you can move forward to fill the gap. Why did he not go forward to pray in it? It is him who was negligent about this place." [End of quote]
As for the second matter, if you imitate a scholar who is of the view that the prayer of the one who prays individually behind the row is absolutely invalid, as it appears from your question, then if you come in the third Rak'ah and there is a gap in the row and there is a person who stood alone behind the row, then you stand in this gap. But if there is no gap in the row, then it is not permissible for you to stand alongside with this person if you believe that his prayer is invalid, because according to your belief, he would not be praying (since his prayer is invalid). So, you should wait until another person comes to stand in line with you. This is the implication of the view of the Hanbali School who consider that the prayer of a person who prays alone behind the row is absolutely invalid (regardless of any detail).
It should be noted that the details that we quoted from Shaykh Ibn Taymiyyah is the view that what we consider to be preponderant.
Allah knows best.
You can search for fatwa through many choices