Firstly: the basic principle is that the prayer should be offered in the mosque, and this is what the mosques were built for. In the hadeeth of Ibn ‘Abbaas (may Allaah be pleased with him) the Prophet (peace and blessings of Allaah be upon him) said: “Whoever hears the call (to prayer) and does not respond, there is no prayer for him (i.e., his prayer is not valid), unless he has an excuse.”
Narrated by al-Tirmidhi (217) and Ibn Maajah (793); classed as saheeh by al-Albaani in Saheeh Ibn Maajah (793).
And the Prophet (peace and blessings of Allaah be upon him) said to Ibn Umm Maktoom (may Allaah be pleased with him): “Can you hear the call to prayer?” He said: Yes. He said: “Answer it.” Narrated by Muslim (653).
This hadeeth indicates that it is obligatory for the one who hears the call to respond, and to pray in congregation in the mosque.
What is meant by hearing the call is that one can hear the voice of the muezzin if he raises his voice with the adhaan, without using a loudspeaker.
Whoever is close to the mosque and can hear the call is obliged to pray in congregation in the mosque, but whoever is far away is not obliged to attend the mosque.
See the answer to question no. 20655.
With regard to their saying that they perform the prayer in congregation and thus fulfil the condition of praying in congregation, they should note that two things are required of them:
1-They should pray in congregation
2-This congregation should be in the mosque.
It is essential to do both things together. This has been explained in the answer to the question referred to above. See also question no. 72398 .
Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) said:
The basic principle is that prayer should be offered in the mosque, but there is nothing wrong with office workers praying in their offices if going out to the mosque will adversely affect their work, or will lead to some employees playing about if they go out to pray and come back late. If the mosque is far away, it is permissible for them to pray in the workplace.
What matters is that if there is a reason or a need for them to pray in their offices, there is nothing wrong with that. End quote.
Majmoo’ Fataawa Ibn ‘Uthaymeen (15/68).
These people should pray in the mosque so long as the mosque is close by, and it is not permissible for them to pray in their offices unless there is a reason, such as if there is the fear that this may cause employees to waste time and so on.
And Allaah knows best.