When a user is enrolled in a course and is also member of one or more groups in that course, it is possible that notifications remain for that course after the user is removed from it.
I think the cause is a race condition in AbstractMemberListController.doLeave(). repositoryManager.removeMembers() moves the deletion process to the thread pool. When executing RepositoryEntryMembershipProcessor.processIdentityRemoved() the remaining roles list is not necessarily empty.
It seems that changing the two lines in AbstractMemberListController.doLeave() solves the problem: