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.
There is disagreement among Muslim scholars concerning if it is legal for one to perform a prayer at his place of residence with the intention of following an Imam who performs the prayer in congregation in the mosque, and the follower either sees the Imam or hears his voice or sees another person who follows the Imam or hears him.
According to the Maaliki and Hanafi Schools of jurisprudence, and a narration from Imam Ahmad, the above-stated situation is legal and permissible. According to the Shaafi'i School and another narration of Imam Ahmad, the above-stated situation is illegal and impermissible, and the prayer performed is void. We think that this last opinion is nearer to what is correct.
Imam An-Nawawi said: “‘If one performs a prayer at his place of residence with the intention of following the congregation at the mosque and there is some barrier between them, the prayer is not valid.’ Ahmad and Maalik said, ‘It is valid except if one performs the Friday prayer.’ Abu Haneefah believes that it is completely right and sound.”
Allah knows best.