This error generally occurs when external collaboration has been restricted. Make sure that the "Allow invitations to be sent to any domain (most inclusive)" setting is enabled and that the least restrictive settings are included, like below:
The users also need redeem the guest user invitations, and the error can sometimes occur if they have not done so.