def _needs_group_expansion(filter_, filter_value, sub_scope):
    """
    Check if there is a requirements to expand the `group` scope to individual `user` scopes.
    Assumptions:
    filter_ != Scope.ALL
    """
    if not (filter_ in {'user', 'server'} and 'group' in sub_scope):
        return False
    if filter_ in sub_scope:
        return filter_value not in sub_scope[filter_]
    else:
        return True
Check if there is a requirements to expand the `group` scope to individual `user` scopes.
Assumptions:
filter_ != Scope.ALL
jupyterhub/scopes.py