There are differences of opinion amongst the poskim on permissibility of permanent use of an upper story flat from a shul. There are circumstances to permit its use, however, the Mishna Berurah seems to counsel against relying on leniencies in this regard where possible