2FA codes not received on Messages in macOS

I use Messages on macOS (both Catalina and now Big Sur) with iCloud syncing on.

I can receive and send messages from/on macOS. Except for 2FA codes. These codes, from any service I've used, only arrive on my iPhone, and not on any of the Mac computers I'm logged in with iCloud.

I haven't figured out a way to fix this issue. 2FA codes used to work a while ago (I used the auto-completion feature when login into Twitter or GitHub from Safari on macOS), but at some point they stopped coming in.

Thanks,
Eneko