The Prophet of Allah ﷺ used to say, "Spitting in the mosque is a sin, and its expiation is to bury it."
حدثنا بهز حدثنا أبان بن يزيد حدثنا قتادة حدثنا
أن نبي الله ﷺ كان يقول التفل في المسجد خطيئة وكفارته دفنها
Its isnad is sahih. It was mentioned earlier at 13825.