Praise be to Allah.
Firstly: Praying (offering du‘aa’) for one’s brother in his absence is something that is encouraged by Islamic teachings.
Islam encourages the Muslims to pray for one another in their absence, as in the hadith of Abu’d-Dardaa’, who said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “There is no Muslim who prays for his brother in his absence, but the angel will say: And you will have something similar.” Narrated by Muslim (2732).
Al-Qaadi ‘Iyaad (may Allah have mercy on him) said:
He will have a reward commensurate with what he prayed for, because even though he prayed for someone else, in fact he did two righteous deeds, the first of which was remembering Allah (may He be exalted) and showing devotion to Him alone, turning to Him in his words and in his heart. The second was loving good for his Muslim brother and praying for him, which is doing good for a Muslim, and he will be rewarded for that. The hadith states that the du‘aa’ will be answered.
End quote from Ikmaal al-Mu‘allim (8/228).
The hadith limits this virtue to cases where du‘aa’ is offered in the person’s absence. But if the Muslim speaks of what he has done, does this invalidate this virtue and reward?
The basic principle in Islamic teaching is that deeds are judged according to the aims and intention (niyyah) of the doer, as the Messenger of Allah (blessings and peace of Allah be upon him) said: “Deeds are but by intentions and each man will have but that which he intended.” Narrated by al-Bukhaari (1) and Muslim (1907).
Telling the one for whom you prayed that you prayed for him in his absence
Based on that, telling the person for whom you prayed in his absence may have several aims:
If the intention behind it is to tell the one for whom you prayed about your kindness and reminding him of your favour, then reminding people of favours is a major sin and may lead to loss of the reward for that of which you reminded your brother.
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) said:
What happens after one finishes an act of worship will not affect it at all, unless it involves a transgression, such as reminding someone of one’s favour or saying hurtful words after giving charity. This is a transgression and the sin incurred thereby cancels out the reward for giving charity and thus invalidates it, because Allah (may He be exalted) says (interpretation of the meaning): “O you who have believed, do not invalidate your charities with reminders or injury” [al-Baqarah 2:264].
End quote from al-Qawl al-Mufeed (2/162).
Informing him of that may be a righteous deed for which the one who does it will be rewarded, such as telling him that he prays for him in his absence in response to a question, in which case telling him about that is by way of ensuring that he is speaking the truth, or he wants to demonstrate his care for the one for whom he prayed and make them feel happy, and increase the love and affection between them, as is mentioned in the hadith. It was said: O Messenger of Allah, who is the dearest of people to Allah?
He said: “The one who most benefits the people. And the dearest of actions to Allah is joy that you bring to a fellow believer…”
Narrated by Ibn Abi’d-Dunya in Qada’ al-Hawaa’ij (p.47); classed as hasan by Shaykh al-Albaani in as-Silsilah as-Saheehah (2/575).
Another example of that is what was narrated by al-Khateeb al-Baghdadi in Taareekh Baghdad (4/325) with his isnaad from Khattaab ibn Bishr: he said: I asked Abu ‘Abdillah Ahmad ibn Hanbal several questions, and he answered me, and each time he turned to the son of ash-Shaafa‘i and said: This is what we learned from Abu ‘Abdillah – meaning ash-Shaafa‘i.
Khattaab said: I heard Abu ‘Abdillah Ahmad ibn Muhammad ibn Hanbal talking to Abu ‘Uthmaan about his father, and Ahmad said: May Allah have mercy on Abu ‘Abdillah; I never offer any prayer but I pray for five people in it, and he is one of them.
With regard to such good purposes, that does not seem to be any reason to disallow that; rather these are good and righteous deeds, and it does not seem that they would have any negative impact on the reward for praying for someone in his absence, or that the one who offers that supplication would not have something similar to what he prays for for his companion.
But he should not ask that person to pray for something similar for him, or to offer supplication for him in return for his offering supplication for him in his absence. What appears to be the case is that this is asking for reward from someone else in return for doing a righteous deed.
We have previously discussed in detail the ruling on asking others to offer supplication (du‘aa’) for you. See the answer to question no. 163632.
And Allah knows best.