Gimbal stops tracking when flight mode is changed

As the title says, when I switch from Auto mode to Loiter or RTL the gimbal stops tracking the ROI. Idk if this is on purpose but I’d rather have the gimbal keep tracking the target at all times. I am sure there must be a simple code line that is making this change. If anyone could please tell me where to find it, I will make the change and compile the code for my particular case.
Thank you!