The short answer is that the function wasn’t handling 429 Too Many Request errors properly. I’m sorry for the trouble with this.
If you need a hand fixing the usernames, I can give you a script to clean them up.
From what I understand, users who were created through the add_user_to_discourse_group function shouldn’t have any trouble logging into your forum with SSO. When they do login, they will have an SSO record associated with them. SSO records are associated with existing users through the email address, not the username, so the number appended to the name won’t cause a problem.
The way this function works, and all other functions that are syncing WordPress/Discourse users for sites using SSO will be completely changed in the next update. I’ll try to have that out on Friday. I realize that doesn’t solve your problem. Thanks for letting me know about this.