Any acquisition involving foreign commerce is subject to the approval of the CFIUS (Committee on Foreign Investment in the United States). Following is an explanation taken from a recent Congressional Research Service report [1] (page 5).
"These regulations created an essentially voluntary system of notification by the parties to an acquisition [...]. Despite the voluntary nature of the notification, firms largely comply with the provision, because the regulations stipulate that foreign acquisitions that are governed by the Exon-Florio review process that do not notify the committee remain subject indefinitely to divestment or other appropriate actions by the President. The regulations make it clear that the President alone determines 'whether a transaction threatens national security.'"
When ByteDance acquired TikTok, they chose not to undergo that review. This was their legal right. However, that made their acquisition liable to be retroactively disallowed by the President.