united-states
If they have a contract with the employee which specifies that such IP is assigned to the company at creation, such a contract is valid until and unless a court holds that it is void. It might be held void as against public policy,. or as being "unconscionable", but it might well not be so held.
An even broader contract, which claimed any and every kind of IP created by an employee, even if crated during off hours and not at the work site nor with company resources is more likely to be held void, but even this is not certain to be held void.
In the absence of a contract explicitly assigning such IP to the company, the company might attempt to apply the rule that makes works created by an employee within the scope of employment works-made-for-hire (WFH). This is in 17 USC 101 (the definitions section of the copyright law). This would affect copyrights, but not patents or other IP.
There is very little US case law interpreting the "scope of employment". But there seems some reason to believe that work that was not assigned by the employer, not intended to benefit the employer, not used by the employer, not done within usual working hours nor using company resources, and not of the specific type normally assigned to or carried out by the employee, is probably not "within the scope" of the employee's employment. If that is so, the work would not be WFH, and only an explicit written contract, signed by the employee (or the employee's authorized agent) could transfer the copyright.