There’s a trope known as “What You Are In The Dark”, and it’s really useful for showing your audience what kind of person a character is.
It’s essentially where a character, usually- but not always- the protagonist, is in a uniquely tempting situation. They have the opportunity to do something they want to do, something that’s selfish and usually, objectively wrong. They WANT to do it on some level, it’s a benefit, and there won’t be any negative consequences for them. And the cherry on top: Nobody who’s opinion they care about will ever know what they’ve done.
Sometimes, it’s something like not saving someone who was horrible to you. Sometimes it’s a little more active, like an alter ego they can use to express their desires. But it’s always, metaphorically speaking, “in the dark”. Nobody sees, or anyone that sees doesn’t know it’s them, or nobody they care about sees and knows it’s them.
What the character does in that situation tells the audience who that character really is. What they’re like under any facades or pleasantries they may put up. What you are in the dark defines you. You are at your most YOU when nobody is looking.
Usually, if the character is a hero, they’ll throw away this opportunity. They’ll face the little voice whispering, “No one will ever know,” and tell it, “I’LL know.” Because they know whatever they have the chance to do is wrong, and they know they’d be torn up about it. Even with no external restrictions, there’s a little guiding force telling them to do good, or at the very least, NOT do evil.
If the character takes the opportunity to do something bad when no one is looking, they’re not a good person.
And yes, this trope CAN be invoked accidentally.