code: private Optional<String> getRequestGroupForTask(final SingularityTaskId taskId, SingularityUser user) {
      Optional<SingularityTaskHistory> maybeTaskHistory = getTaskHistory(taskId, user);
      if (maybeTaskHistory.isPresent()) {
        SingularityRequest request = maybeTaskHistory.get().getTask().getTaskRequest().getRequest();
        authorizationHelper.checkForAuthorization(request, user, SingularityAuthorizationScope.READ);
        return request.getGroup();
      } else {
        return getRequestGroup(taskId.getRequestId(), user);
      }
    }
docs: Finding request group