What is the ruling if attending a mosque might cause distress to its Imam or congregation?

Chapter on Imamate and Congregational Prayer

Al-Mughni

Book of Prayer

Book 3 · Issue 4 · Bab 10

Open in Qurani

Primary text

If one's attendance at a mosque is intended to avoid attending another, thereby causing grief to its Imam or congregation, then mending their hearts (by attending their mosque) is preferable.