What is the ruling on prayer shortening for a traveler passing through their hometown?

Chapter on the Traveler's Prayer

Al-Mughni

Book of Prayer

Book 3 · Issue 2 · Bab 11

Open in Qurani

Primary text

If a resident of Baghdad travels to Kufa, but stops at Nahrawan due to necessity, and then passes through Baghdad while proceeding to Kufa, they pray two rak'ahs if they are merely passing through Baghdad without intending to reside there.