A compromised Gmail account does not, by itself, mean that a virus or worm was installed on your MacBook Pro.
Someone who gained access to your Gmail account could also access your contacts without your Mac being infected.
Start by securing your Google account.
From a device you trust, change your Google password and review your account’s security activity for unfamiliar devices or activity.
Check Gmail for unauthorized forwarding, filters, delegation, or automatic replies, and review the third-party apps and services connected to your Google account.
Remove anything you do not recognize, and enable two-step verification or a passkey if you have not already done so.
Google Account Security
Next, think about what happened after you clicked the invitation link. In particular, determine whether you downloaded or opened a file, installed an application or browser extension, entered your Mac administrator password, or approved a macOS security or privacy request.
Those details are important because they help determine whether there is a reason to investigate the Mac further.
On the Mac, check System Settings >> General >> Login Items & Extensions and Applications for anything you do not recognize.
Also check your browser's extensions and website permissions. An unfamiliar item is not necessarily malicious, so it should be identified before being removed.
Keep macOS and your browser up to date.
Apple includes built-in malware protections such as XProtect, which receives automatic security updates.
Apple explains these protections in its Platform Security documentation.
There is no single macOS check that can conclusively prove that a Mac is free of all possible malware.
However, based on what you have described, there is no specific indication that a virus or worm was installed. Your Mac continuing to work normally also does not, by itself, prove or disprove an infection.
The Gmail and contact compromise therefore should not be taken as evidence that your Mac was infected or specifically targeted.