The Prophet (ﷺ) said: If anyone prays over the dead in the mosque, there is nothing on him.
Sunan Abi Dawud Book 21, Hadith 103