comma before because

Are these sentences both correct:

[color=blue]1-He wasn’t pleased that I had paid him a visit because he wanted to be alone with his girlfriend.

[color=red]2-He wasn’t pleased that I had paid him a visit, because he wanted to be alone with his girlfriend.

In ‘2’ there is a comma before ‘because’.

Gratefully,
Navi.

‘He wasn’t pleased with my visit because he wanted to be with his girlfriend alone’, I think, would be better. Wait for other comments.
(When we begin a sentence with a subordinate clause, we use a comma after it as in this very sentence.)

Yes, both are correct (and sound better to my native English speaker’s ear than THLs alternative)