The Messenger of Allah ﷺ said, "None of you should stand for prayer while feeling the urge to relieve himself."
حدثنا أبو بكر بن أبي شيبة حدثنا أبو أسامة عن إدريس الأودي عن أبيه
قال رسول الله ﷺ لا يقوم أحدكم إلى الصلاة وبه أذى
[Sahih] Ibn Abu Shayba narrated it: 2/422, with this wording, and Busiri said, "Its narrators are trustworthy, and it has corroborating reports."