Scams mostly target people these days. Us. Not our iPhones. This scam certainly did. It didn’t target your iPhone. It targeted you, lied to you, and lied about the existence of malware.
Your iPhone is fine.
We’re all unfortunately swimming in advertising, scams, campaigns, propaganda, and the rest of the rubbish, and there’s no shortage of that on Facebook.
Recognize and avoid phishing messages, phony support calls, and other scams - Apple Support
Can an iPhone be exploited? Yes. It’s been very rare, and very targeted, based on all available information. It doesn’t pop up “Trojan virus” messages, and the exploits don’t—as was probably the case here—seek to convince you to install some app store app you don't need for a problem you don’t have, and that hasn’t existed in a decade or so. If you’re an investigative journalist, political dissident, with access to financial info or great wealth, with access to sensitive or classified data, senior in government or private organization, or such, the calculations of your risk here might shift. But that won’t show as a “trojan virus”.