Why does my dog only like my boyfriend when my mom is not home?

Whenever my boyfriend comes to my house and my mom is home, she growls and barks at him. She never lets him pet her and she is seemingly scared of him sometimes, too. However, my parents just went on vacation for 2 weeks and my dog seemed to love him while they were away. They just got back a few days ago and she’s already back to “hating him”.