most of the time you just roll the dice. As long as what you're doing is not in the same line of business as your employer, and you part on good terms, most of the time it's fine.
This is actually a good distinction. If your side project is related to your employer's line of work then it is easy for your employer to argue that they own that creation, even if you used a personal computer and did it at night, etc.
So for example if your employer makes inventory management software for coffee shops, and you decide to make an inventory management tool for grocery stores... then your employer will easily own your creation.
On the other hand if you work for a search engine platform (ie Google), and you invent an API tool that parses recipes, and you did it all on your personal laptop and personal time, then you should be fine.