Honestly, I don't see anything wrong with how you reacted. If she was with you, and the guy knew it, you imposed yourself. Better than being a cuck.
But, if even after you went there and talked to him, the girl went back to the guy to talk with him, honestly, I think SHE needs to get better...