The term you are looking for is "compersion." Compersion is the feeling of joy, happiness, or pleasure that one experiences when witnessing or knowing that others are happy, joyful, or experiencing pleasure. It is often used in the context of romantic or interpersonal relationships, especially in the context of consensual non-monogamous or polyamorous relationships.
In contrast to sadism, which involves deriving pleasure from inflicting pain or suffering on others, compersion involves deriving pleasure from the happiness and well-being of others. It is often considered a positive and empathetic emotion, reflecting a person's ability to find joy in the happiness of those they care about, even if it doesn't directly involve them.