Barriers to Compassion
With practice, you can be content by reflecting on the good karma of others rather than joy or happiness. It is very close, if not the same, to praise. For example, if someone you're showing compassion to is now able to feel happy, then you can think "Now this person has the opportunity to practice dhamma since his problems are lesser. This is good". Maybe you can go further and help the person practice dhamma even for a second. This way, you don't cultivate thoughts that nurture attachment, nor do you appreciate any wrong joy or happiness in the other person you helped (such as thanha).