Previously, reset_course_userdata() was deleting the role_capabilities directly, but has_capability() checks the local capabilities cache which was still returning the previous value.