Roy was trying to win Pam back as he understood he took her for granted before as he once said in S03E01
Roy: After Pam dumped me, I um, I kinda stopped taking care of myself
there, and uh, I hit bottom when uh, drunk driving arrest. I've been
working out and um, you know, I'm not gonna take her for granted. I
gotta win her back.
This shows he was clearly hurt. But while he wanted to win her badly, seeing Pam dancing and later talking to another man at Diwali, Roy probably got more upset and decided to leave rather then stay and talk to Her. He saw Pam is clearly less worried about their breakup and seems much happier, he couldn't watch that.
He could have stayed for the sake of Pam but I think sure Roy was trying to win her but as he by nature is not very caring or affectionate , he could not try and get Pam to like him.