I have had a similar issue with an ArcPy script that is part of an ongoing project. ArcPy script in a Notebook run in ArcGIS Pro. Mine is intended to automate cartographic production; it cycles through calc'ing some fields based on imports from an Excel file, then exporting a layout, wash rinse repeat.
My issue was that not all the layers would draw/refresh in the automated map export. I confirm that the data has actually been updated, and if I refresh the layout manually in Pro, the symbols/labels update per calculated data. But during troubleshooting, often there was a single stubborn layer that would not show up in the automated layout export.
For my first iteration of the script, I was never able to nail down exactly what the issue was, but I defeated it by including an extra map frame, hidden beneath the main map frame, and if that frame was active during the script run, things exported correctly (I know, bizarre 😅).
Incorporating additional functionality into the script now and my old nemesis is back. This is a new thread since I last searched here, so following to see if anyone comes up with any insight on how to force the layout to refresh before exporting it.
Initial iteration of script.