Fiqh-us-Sunnah Volume 2, Supererogatory Prayer, Fiqh 2.061.

Section : Following the imam with a barrier in between.

It is allowed for a follower to follow the imam, even if there is a barrier between them, as long as he or she can tell the imam’s movements either by his sight or hearing.

Al-Bukhari records: “Al-Hassan said: ‘There is no problem if you pray and between you and him [the imam] there is a river.’ Abu Majliz said: ‘Follow the imam, even if between you and him there is a road or a wall, as long as you can hear the opening takbir.'” We have already mentioned the hadith in which the people prayed behind the Prophet sallallahu alehi wasallam while they were behind the room.