Your understanding is correct. Groups are always inherited from the parent process (init starts with no supplementary groups). The only way this is ever changed is by setgroups. This is done by su, sshd, or whatever privileged process performed the login for the user. By the time the user's shell runs, the groups are already set.