All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
Many scholars who are of the view that it is obligatory to perform the five daily prayers in congregation do not say that it must performed in the mosque; rather, it is sufficient to perform it in congregation in places other than the mosque.
Even the scholars who are of the view that it is obligatory to perform the five daily prayers in congregation in the mosque hold that this applies to those who are near the mosque in such a way that they hear the Athaan without a loud speaker, and they do not hold that it is obligatory on someone who is far away and cannot hear the Athaan, as we have already clarified in Fataawa 82264and 89364.
Therefore, if you do not pray in the mosque, you are obligated to perform the prayer in congregation at home. If you find someone who can pray with you in congregation, then this is good; if not, you are not sinful, because Allaah does not charge a soul beyond its capacity, and in this case, you may perform the prayer alone.
If you find someone who has already began praying before you, then you may join him, and the fact that he did not intend to be in congregation is not of any harm. However, if joining him makes him angry and aversive, then do not join him and pray alone, because obligations are canceled by sound excuses, and warding off harm takes precedence to bringing about a benefit.
Allaah Knows best.