Sunan Ibn Majah Book 15, Hadith 27
“Whoever leaves behind money, it is for his heirs, and whoever leaves behind a debt for children, I am nearer to the believers.”
if a believer died at the time of the Messenger of Allah (ﷺ) and he had debts, the Messenger of Allah (ﷺ) would ask: “Did he leave anything with which to off his debt?” If they said yes, then he would offer the funeral prayer for him, but if they said no, then he would say: “Pray for your companion.” When Allah granted his Prophet (ﷺ) the conquests, he said: “I am nearer to the believers than their own selves. Whoever dies owing a debt, I will pay it off for him, and whoever leaves behind wealth, it will be for his heirs.”
Whoever is easy with (a debtor) who is in difficulty, Allah will be easy with him in this world and in the Hereafter.”