Whenever the prayer was being established in the mosque, the Messenger of Allah ﷺ would sit down and not pray if he saw the people were few, but if he saw them gathered in a sizable group, he would pray.
حدثنا عبد الله بن إسحق الجوهري أخبرنا أبو عاصم عن ابن جريج عن موسى بن عقبة
كان رسول الله ﷺ حين تقام الصلاة في المسجد إذا رآهم قليلا جلس لم يصل وإذا رآهم جماعة صلى
[Sahih] Bayhaqi reported it, 2/20, and the following hadith serves as a corroborating witness for it.