Praise be to Allaah.
Praying in congregation is obligatory.
This is what is indicated by the shar’i evidence from the Qur’aan and Sunnah. As Allaah has enjoined prayer in congregation in the battlefield, so it is more appropriate that it is obligatory at times of stability and peace. This has been discussed in the answer to question no. 120 and 8918.
It is obligatory to pray in congregation in the mosque, not in workplaces or schools.
This applies if the Muslim is accountable, male, able to do it and can hear the adhaan without the aid of a loudspeaker.
This is indicated by the fact that the Prophet (peace and blessings of Allaah be upon him) thought of burning down the houses of those who prayed at home, even though they may have prayed in congregation.
It was narrated that Abu Hurayrah (may Allaah be pleased with him) said: The Messenger of Allaah (peace and blessings of Allaah be upon him) said: “I was thinking of ordering that the iqaamah for prayer be given, then I would tell a man to lead the people in prayer, and I would set out with men carrying bundles of firewood, and go to people who do not attend the prayer and burn their houses down around them.” Narrated by al-Bukhaari (657) and Muslim (651).
This has been discussed in the answer to question no. 72398.
Hence there is no comparison between prayer in congregation at home and prayer in congregation in the mosque. The reward and virtue come from praying in congregation in the mosque. The one who does not pray in congregation in the mosque and chooses to pray in congregation at home or in the workplace does not attain the reward of praying in congregation in the mosque, if he is free from sin in the first place.
The one who has an excuse for not attending prayer in congregation in the mosque will have the same reward as those who pray in congregation, even if he prays at home.
A Muslim may be excused for not praying in congregation in the mosque, such as if he is far away and the sound of the adhaan in its natural form does not reach him, or he is sick, or afraid. If that is the case, then he should pray in congregation with the members of his family who are not obliged to pray in congregation, or those who have a similar excuse. Here it is valid to differentiate between the congregation in the mosque and the congregation of these people in terms of numbers. The congregation that is greater in number is more beloved to Allaah – and we shall quote the relevant hadeeth below – but there is no room for comparison of other rewards, such as the number of steps that the worshipper takes to the mosque, or coming early to pray, and Allaah preparing a welcome in Paradise every time he comes and goes, and so on. These rewards are denied to the one who prays in his house, unless he is one who regularly prays in the mosque but is kept from doing so by sickness or some other reason, in which case a reward will be decreed for him like that which he used to do, as is stated in a saheeh hadeeth from the Prophet (peace and blessings of Allaah be upon him).
Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) said:
For the one who is excused, the reward will be decreed if it was his habit to pray in congregation, because the Prophet (peace and blessings of Allaah be upon him) said: “If a person falls sick or travels, there will be decreed for him a reward like that for what he used to do when he was healthy or not travelling.”
Al-Sharh al-Mumti’ (4/323).
If a man does not have anyone to pray with, he may pray alone, but the more people who pray, the dearer that is to Allaah.
If a person deliberately misses the first jamaa’ah (prayer in congregation), he is sinning, but his praying in congregation is better than his praying alone, although he will not have the reward of the first jamaa’ah
Those who delay it without any excuse and aim to pray with the second or third jamaa’ah – as happens in some marketplace mos
[Ruling on prayer in congregation for men - islamqa.info] is good,have a look at it! https://islamqa.info/en/40113
Full link [emoji115]
According to the Hanafis , it's wajib for one without any valid excuse.