It is narrated from Sayyiduna Abu Hurairah (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "When you see someone buying or selling in the mosque, say: May Allah not grant profit in your trade. And when you see someone searching for a lost item and announcing it in the mosque, say: May Allah not return your item to you."
Hadith Referenceسنن دارمي / من كتاب الصللاة / 1439
It is narrated in Sahih Muslim: Mosques are not built for the purpose of buying and selling or searching for lost items therein.
It is thus understood that these actions and deeds are not permissible in the mosque, and if someone makes such an announcement, then it is permissible to say the aforementioned words as a supplication against him.