All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger. We ask Allaah to exalt his mention as well as that of his family and all his companions.
I think that the questioner is referring to the narration which is narrated by Ibn 'Abbaas who said: ''The Prophet said: ''Indeed death is dreadful, if one of you hears of the death of a friend, he has to say: ''Innaa lillaahi wa innaa ilayhi raaji'oon" (to Allaah we belong and unto Him is our return), O Allaah, write him as a beneficent, and record him amongst the dwellers of Paradise and preserve his offspring after him. O Allaah, do not deprive us from the reward of the supplication we just made in his favor (and all actions related to the funeral), and do not cause us to divert after his death." [At-Tabaraani]
The authenticity of this narration is not agreed upon by all scholars, but even if this Hadeeth is authentic, it should not be said about a non-Muslim who dies, because it is not permissible to supplicate to Allaah to write him down as a beneficent and to make him amongst the dwellers of
Allaah knows best.