PHP variable not regenerating when publishing multiple posts at the same time

Context: I am building an automated system which will grab record from a database and immediately publish them en masse as a CPT. When they are being published, I have a function in the functions.php file of a child theme that should automatically set two categories to the post, a “fixed” one called ‘People’, and another one based on a column (categ) which is part of the record sent with the post.