I know the boyfriend is a yandere, but this friend guy is kinda scummy too.
The girl does not feel safe and he saw that as an opportunity to steal her away. Maybe just wait for things to get resolved first before confessing huh? Maybe prioritize her safety first before trying to get to her while...