Notification issue, Please help

We are facing notification issue on erpnext version 12.18.0

Error log

Traceback (most recent call last):
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/email/doctype/notification/notification.py", line 334, in evaluate_alert
    alert.send(doc)
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/email/doctype/notification/notification.py", line 123, in send
    self.send_an_email(doc, context)
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/email/doctype/notification/notification.py", line 158, in send_an_email
    recipients, cc, bcc = self.get_list_of_recipients(doc, context)
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/email/doctype/notification/notification.py", line 216, in get_list_of_recipients
    emails = get_emails_from_role(recipient.email_by_role)
  File "/home/adminuser/frappe-bench/apps/frappe/frappe/core/doctype/role/role.py", line 33, in get_emails_from_role
    user_email, enabled = frappe.db.get_value("User", user.parent, ["email", "enabled"])
TypeError: 'NoneType' object is not iterable

We know a user who was in that role cause the issue, but we don’t know why and how to fix it. that new user synced from ldap with wrong email address at beginning, so we corrected the email address and name in tabUser, and after that the issue appeared.
of course we don’t know what will happen before the email address corrected.

Thanks.

Update

The issue has been fixed by me.
the key step is run below command in bench console.

frappe.get_list("Has Role", filters={"role": 'Market Manager', "parenttype": "User"},fields=["parent"])

(Market Manager is the name of role)
This command comes from the function get_emails_from_role.
And I got the result.

[{'parent': 'AAA'}, {'parent': 'BBB'}]

now I realized that the name modified at beginning cause the record duplicated in table Has Role, so either remove old BBB or modify BBB to AAA