You don't have to be evil to legislate that foreigners can't own sensitive companies. For instance, defence contractors. In this case TikTok is considered to have vast access to the personal information and habits to many millions of Americans and is considered a security risk. That they tried to manipulate users into a political action did not help their cause at all. This seems to be self inflicted.
But the headline is misleading anyway, it's not a ban it's a forced sale with a ban as a last reort.