Al-Shafi‘i validates following in some cases where imam and follower are performing different obligatory prayers, placing weight on their compatible acts of following despite distinct intentions.
The Hanafi position requires alignment in the specific identified obligatory prayer; Zuhr and Asr are separate obligations.