In his book, Al-Fiqh `ala al-Madhahib al-Arba`ah (Fiqh of the Four Schools of Thought), Sheikh `Abd Ar-Rahman Ag-Gazery states the following:
“According to the four schools of fiqh, a person is allowed to pray behind an imam who is praying an obligatory Prayer while he is intending to pray an optional Prayer. But, they differed regarding praying obligatory Prayers behind an imam who is praying optional Prayers; the Shafi`i school of Fiqh see no problem in this.”
Based on the above quotation, it becomes evident that one is allowed to pray an obligatory Prayer behind a man who is praying a supererogatory Prayer and vice versa.