This is a very broad provision, broader than that which many companies use, but that does not make it unlawful or invalid.
The key phrase in the quoted part of the agreement is "while employed by COMPANY". The relevant phrase from copyright law (17 USC 101) is "within the scope of his or her employment" The first is broader than the second.
According to the LII page "Scope of Employment](https://www.law.cornell.edu/wex/scope_of_employment):
The phrase “scope of employment” is a common law concept that often arises in civil litigation, especially in workers’ compensation cases and personal injury cases. Generally, the scope of employment is the range of activities and conducts that an employee is reasonably expected to perform as part of his or her job.
The page "Introduction to Agency Law" from hr Boise State Business Law series states:
In general, the broadest liability is imposed on the master in the case of tortious physical conduct by a servant or employee. If the servant or employee acted within the scope of their employment—that is, if the servant’s wrongful conduct occurred while performing their job—the master will be liable to the victim for damages unless, as we have seen, the victim was another employee ...
Legal Match's page Scope of Employment Definition reads:
In legal terms, the scope of employment refers to the range of activities that an employee is reasonably expected to participate in as part of their job duties.Within this range of activities, the employer could be held liable for their employee’s actions when a third party is injured or otherwise negatively affected by the employee’s conduct. The term is often used in personal injury cases.
When the scope of a person’s employment is questioned, it is generally to determine whether an employee’s actions during an accident were part of their job. If not, it would be said that the actions in question fell outside the scope of employment.
In all these sources, "within the scope of employment" is equated to "while performing their job" or being within "the range of activities and conducts that an employee is reasonably expected to perform as part of his or her job".
The US Copyright Office's Circular 09 "Works Made for Hire" discusses the tests fore who is an employee in some detail, but does not discuss the "scope of employment".
The only US Supreme Court case, since the passage of the Copyright Ac of 1909, to deal with whether a work is a work made for hire is Community for Creative Non-Violence v. Reid, 490 U.S. 730 (1989) In that case the Court held that Reid was not an employee, so only the second section of the definition in 17 USC 101 (the "specially commissioned" section) was relevant. The Court held that the work was not a work-made-for-hire because it did not fit any of the limited set of categories specified in the law, and otherwise did not fit part 2 of the 17 USC 101 definition because there wass no written agreement making the work a work-for-hire. The court did not consider the first part of the definition beyond its finding that Reid was not an employee.
However, in the Community for Creative Non-Violence v. Reid opinion Justice Marshall wrote:
[490 U. S. 739-740] In the past, when Congress has used the term "employee" without defining it, we have concluded that Congress intended to describe the conventional master-servant relationship as understood by common law agency doctrine. See, e.g., Kelley v. Southern Pacific Co., 419 U. S. 318, 419 U. S. 322-323 (1974); Baker v. Texas & Pacific R. Co., 359 U. S. 227, 359 U. S. 228 (1959) (per curiam); Robinson v. Baltimore & Ohio R. Co., 237 U. S. 84, 237 U. S. 94 (1915). Nothing in the text of the work for hire provisions indicates that Congress used the words "employee" and "employment" to describe anything other than "the conventional relation of employer and employe.'" Kelley, supra, at 419 U. S. 323, quoting Robinson, supra, at 237 U. S. 94; compare NLRB v. Hearst Publications, Inc., 322 U. S. 111, 322 U. S. 124-132 (1944) (rejecting agency law conception of employee for purposes of the National Labor Relations Act where structure and context of statute indicated broader definition).
The page "Work Made for Hire Doctrine- Module 1 of 5" from LawShelf states:
One method for having a work qualify under the doctrine is for an employee to create the work when he’s acting within the scope of his job duties. When an employee creates a copyrightable work as part of his job duties, then a court will find that the resulting creative work is a work made for hire and copyrights associated with that work are owned by the employer, not by the individual employee.[3]
The individual who creates the work made for hire must be a true employee, not an independent contractor or consultant. Also, works created by an employee must be created within the scope of his employment to qualify as work made for hire. Allen operates a ceramics shop and hires George as his employee. All ceramics made during employment are owned by Allen but if George creates a ceramic bowl on his own time, in his own home and then sells it later to Allen, the ceramic bowl won’t qualify as a work made for hire, so George will own all rights associated with it. [Emphasis added]
In The Scope of Employment Test Under The Work-Made-For-Hire Doctrine Revisited: How Covid-19, Remote Working, and the Restatement (THIRD) of Agency Could Change It by DIANA J. SIMON (published in UIC REVIEW OF INTELLECTUAL PROPERTY LAW Vol 20 p 232 (2021)) the author writes [footnotes in {braces}]:
This article explores the intersection between
the work-made-for-hire doctrine under the Copyright Act of 1976, agency theory, the updated Restatement (Third) of Agency, and our changing workforce in a postCOVID-19 world. Specifically, as of now, whether an employee was “in the scope of employment” at the time a work was created is evaluated, in part, by whether the work occurred “substantially within time and space limits.” But this test is derived from the Restatement (Second) of Agency, which has been amended, and the Restatement (Third) no longer includes this as a factor. On top of the changing Restatement, employment conditions for many in this country have also changed dramatically. Now, where home is not only where the heart is but where the office is, this raises complex issues about whether the test for scope of employment should change and discusses the implications of such a change.
...
Subsequently, the Fourth Circuit, taking its direction from the Supreme Court, [in Community for Creative Non-Violence v. Reid] applied the Restatement (Second) of Agency in analyzing whether a party, indisputably an employee, created a work within the scope of thier [sic] employment.{in Avtec Sys. Inc. v. Peiffer, 21 F.3d 568, 571 (4th Cir. 1994).} Based on CCNV, the court turned to section 228 of the Restatement (Second) of Agency and laid out the three-part test from that section as follows: A servant’s conduct is within the scope of employment if:
(a) it is of the kind he is employed to perform; (b) it occurs substantially within the authorized time and space limits; [and] (c) it is actuated, at least in part, by a purpose to serve the master. {Restatement § 228 (1958))}
Other circuits then followed suit. Thus, the Copyright Act, and the work-for-hire doctrine became enmeshed with the common-law agency doctrine and the Restatement (Second) of
Agency.
While some commentators and courts alike have characterized the three-part test above as rules that are either “not rigid”{Robert A. Kreiss, Scope of Employment and Being an Employee Under the Work-Made-For-Hire Provision of the Copyright Law: Applying the Common-Law Agency Tests, 40 U. KAN. L. REV. 119, 128} or just factors, none of which are
dispositive,{Kurakyn Holdings, LLC v. Ciro, LLC, 242 F. Supp. 3d 789, 804 (W.D. Wis. 2016)} the courts have not been uniform in this approach. First, the test itself is worded in the conjunctive [and], as opposed to the disjunctive [or], which could be why courts have stated that the test is conjunctive requiring that all three prongs must be
satisfied.{Woodson v. Atlantic City Bd. of Educ., No. 19-14572, 2020 WL 1329918, at *5 (D.N.J. Mar. 23,
2020); Quinn v. City of Detroit, 988 F. Supp. 1044, 1049 (E.D. Mich. 1997); City of Newark v. Beasley,
883 F. Supp. 3, 7–8 (D.N.J. 1995) (noting that “the [employer] must prove all three elements set forth
in the Restatement” because the test is worded in the conjunctive); Roeslin v. Dist. of Columbia, 921
F. Supp. 793, 798 (D.D.C. 1995). Interestingly, in the context of determining vicarious liability using
these same three factors in a tort case, several courts have also held that all three criteria must be met. E.g., Bagent v. Blessing Care Corp., 862 N.E.2d 985, 992 (Ill. 2007); Grager v. Schudar, 770 N.W.2d 692, 699 (N.D. 2009) (observing that the scope of employment determination requires consideration of each element in section 228} Second, some courts refer to the prongs as “elements,” and elements, as opposed to factors, are
a component of a legal test that must be proved . . . and [a]s constituent parts, all of the elements . . . must be proved to establish the legal claim in question. {Michael R. Smith, Elements v. Factors, 39 WYO. LAW. 46, 46 (2016)}
Third, on the time and space factor, some courts have held that the work was not for hire because the employee did the work at home during off hours, and thus, the employer “failed to meet its burden of proof” on the second prong. For example, the United States District Court for the District of Columbia, after stressing that the employer must demonstrate all three factors to prove a work is one for hire, held that
the computer program at issue was not created within time and spatial bounds because the employee spent 3,000 hours outside of normal hours working on it, even though he did test each module at work.{Roeslin, 921 F. Supp. at 798.} Similarly, when a police officer created a workbook and training manual at home during off hours, the court held that the defendant employer utterly failed to meet its burden of proof that the employee used authorized hours to create the work.{Beasley, 883 F. Supp. at 8.}
Nonetheless, several courts have said that the second factor—time and space limits—is given less weight assuming the work was the kind the employee was hired to perform,{E.g., Avtec, 21 F.3d at 571; see also TD Bank N.A. v. Hill, 928 F.3d 259, 277 (3d Cir. 2019)} or have found that the factor was satisfied even though the work was
done at home or during off hours. For example, the Fourth Circuit held that the source code an employee created was within authorized space limits even though it was
created at home because there was no strict differentiation between “work and home or between work hours and off hours.”{U.S. Auto Parts Network, Inc. v. Parts Geek, LLC, 692 F.3d 1009, 1018 (9th Cir. 2012).} Similarly, the Second Circuit held that work done at home was still within authorized bounds because the “very nature of a teacher’s duties involves a substantial amount of time outside of class.”{Shaul v. Cherry Valley-Springfield Cent. Sch. Dist., 363 F.3d 177, 186 (2d Cir. 2004).}
The article then cites Section 7.07 (2) of the Restatement
(Third) of Agency which defines "within the scope of employment as:
(2) An employee acts within the scope of employment when performing work assigned by the employer or engaging in a course of conduct subject to the employer’s control. An
employee’s act is not within the scope of employment when it occurs within an independent course of conduct not intended
by the employee to serve any purpose of the employer
The article goes on to discuss the possible replacement of the 2nd restatement's definition with that from the 3rd. But this distinction is not of great import here.
Conclusion
Unrelated Work is not Work Made for Hire
Work done by an employee, but not assigned by an employer to an employee, nor intended to further an employees job functions, nor of the kind generally done by the employee for the employer, nor dome during work hours nor using company facilities, will not constitute work-made-for-hire under US copyright law.
Thus a computer programmer who, say, writes a novel during off-hours will not have that novel treated as a work made for hire. Indeed an employee hired to create and maintain a database engine will not have work on artificial intelligence visual processing treated as a work for hire.
However, a copyright may be transferred by contract, even if not a work-made-for-hire. The quoted language purports to do exactly that.
The extremely broad terms pf the quoted language might lead to it being held unenforceable if the outside work is clearly not "within the scope of employment" and is of a nature clearly unrelated to the work which the employee has been hired to do. This is not an outcome on which an employee can rely, however. It is very much a case-by-case matter.
A prospective employee could attempt to negotiate for narrower language. Or such an employee could send a written communication, probably by certified mail, expressing that the employee's understanding is that the provision is limited to works "within the scope of employment". This would help to establish that there was no "meeting of the minds" for any transfer of IP outside of such scope.
Such an employee might be wise to consult an IP lawyer on such matters for a more specific and reliable answer.