"get_course_users" and "get_course_students" have been moved to "deprecatedlib", but continue to be used by a number of existing and new code. Unfortunately, when they were modified to use the new roles and capabilities functions they lost some of their existing function.
The "get_course_students" previously would return all users who were considered students at the site level. This was dependent on the "$CFG->allusersaresitestudents" variable being set to true, and excluded users specifically assigned as teachers to the site course. Now, it returns users who have the "moodle/legacy:student" capability. This works if you manually assign users to the 'student' role at the site level. However, the "$CFG->allusersaresitestudents" has been replaced by the "user policies" setting "defaultuserroleid". If this is set to "student", "get_course_students" does not return all the users it should.
Likewise, "get_course_users" previously used the old "get_course_students" and "get_course_teachers". Now, it gets all users with the "moodle/course:view" capability. This capability doesn't seem to get set for a user unless they are specifically given a role with that capability. Setting the "defaultuserroleid" does not do this.
These functions need to be updated to handle the "defaultuserroleid" setting for the site course. And, whatever they are replaced with (after they are removed from "deprecatedlib") also needs to be able to handle this.