Imam an-Nawawi رحمه الله said:
‘These are Ahadeeth which prohibit praising a person in his presence, however there are many authentic Ahadeeth regarding the permissibility of doing this.
The scholars have said: The way we combine these (apparently opposing) Ahadeeth is:
If the one being praised has perfect Iman, certainty, is secure in himself, trains his soul and possesses awareness to the extent that he will not fall in to a Fitnah or deceived by this praise nor will this praise play upon his conscience then in this circumstance it is not prohibited nor is it disliked to praise him in his presence.
If however, any of these above matters are feared and that person is not secure, then it is disliked to praise him in his presence, and it is disliked in the strongest terms. The differing Ahadeeth, are understood in this context and according to this explanation.
(Riyadh as-Saliheen)
If we analyse, there can be four scenarios for praising others in their presence:
The first scenario: That there is benefit in praising him and it is encouragement for him, motivating him to praiseworthy characteristics and noble manners. There is no harm in doing this because it is encouragement for your companion. Therefore if you witness generosity, being good to others, courage and sacrificing and you mention his qualities in front of him to others in order to encourage him and make him firm in order to continue with what he is doing, then this is good.
The second scenario: That you praise him in order to make apparent his excellence amongst the people in order for this praise to spread amongst the people so they respect him, as the Prophet –sallAllahu alayhi wa sallam– did with Abu Bakr, Umar and other Sahaba (RA).
The third scenario: To praise someone and to take it to an extreme and to describe him in a way that he is not worthy of. This is prohibited and it is lying and deception. For example mentioning a leader or minister or someone of this rank and extolling him and describing him with praiseworthy characteristics which he does not possess. This is not permissible and is harmful for the one being praised.
The fourth scenario: someone praises another person with that which he does posses however he fears that the person being praised will be deceived by this and become amazed of his own self and becomes conceited with himself, and raise himself above others. This is also prohibited and not permissible.
Summarised from https://abdurrahman.org/2014/10/08/the-dislike-of- praising-someone-in -their-presence-shaykh-uthaymeen/