Only rebuke when there’s not a conflict of interest; don’t do it because they’ve hurt your friend’s feelings, or to make someone else happy, don’t do it because it will give you an advantage.
Only rebuke when you’ve distanced yourself emotionally; don’t do it if you’re wrestling with forgiving them still, don’t do it if your feelings are going to be controlled by their response.
Only rebuke when you’re humble enough to admit you don’t know their motives; don’t do it if you’ve already decided that they intended evil or were malicious. You’d be rebuking something only God can know – and you’re not God.
Only rebuke when you’ve got the facts; don’t rebuke when you’ve just heard what they did, or when they’ve only told you snippets. Get the whole story from them first, prayerfully hoping that they haven’t sinned at all.
Only rebuke when your real desire is to please God.