Are you sure that there is always a currentuser during checkin?
There is a difference between the natural Jamf check-in that gets started via the LaunchDaemon, versus a manual check-in or policy execution (Self Service, doing sudo jamf policy, etc.) The former gets executed entirely in a root context, whereas the latter ones typically run as the user with elevated rights.
All this is to say, I've seen this type of problem before. What typically has worked for me is to use the launchctl asuser syntax you can find here:
https://scriptingosx.com/2020/08/running-a-command-as-another-user/
If you echo currentuser you might notice that it's root.