Inviting users with groups field failed when there is an existing user in the list

This used to happen before the security fix as per this line of code.

I wouldn’t revert this code before discussing with @tgxworld and he is away for the week.