8.4.2: User doesn't enter group during installation but does after

Permalink
I create a user group during a package installation and want to add the admin right after it:
$config_database = $this->app->make('config/database');
$group_id = $config_database->get('my_user_group');
$group = Group::getByID($group_id);
$site_user = $this->app->make(User::class);
if ($group) {
    $site_user->enterGroup($group);
    $site_user->refreshUserGroups();
}

I check the admin Members page and the admin is not in that group.

But if I use the same code in a Dashboard single page controller in the package, it adds the admin to the group no problem.

How come the difference? Isn't the user during installation the same as after?

linuxoid