Get Workouts from Health Not Working When iPhone Locked

I have a Shortcuts automation that starts when I do a walking workout and uses Toolbox Pro to get my previous walking workout. It then calculates what a 1% increase in pace would be and sends me a notification of how fast I need to do a mile. (My goal is to increase my pace by 1% each time.)

The problem is that this works if I have my iPhone unlocked but won’t work if my iPhone is locked. When it fails, if I go into Shortcuts via the failure notification, I see this message on the “Get workouts from Health action”:

There was an error trying to read workout samples from Health: Protected health data is inaccessible

Is there a way around this or is this something that is just an Apple restriction on third-party apps?