I believe the reproduction process is:
- Invite x@y.com.
- Accept the invite with the wrong account (A).
- Realize your mistake, remove the email address.
- Try to invite the account again.
Expected behavior:
- Invite gets sent.
Actual behavior:
- Address is incorrectly resolved as user A, even though the address is no longer meaningfully associated with them.
The code makes some effort to account for this case but is currently getting it wrong based on observed behavior.