Mexico allows entry if you have a valid stamped US or Canadian visa in your passport.
The visa should be valid for the duration of your stay in Mexico.
If you do not have a stamped visa in your passport, then you should get a Mexican tourist visa before traveling to Cancun.
Example 1
You have an H1B visa stamped in your passport and it is valid for another 1 month. Mexico will allow you to enter Cancun for up to 1 month.
Example 2
You have an expired H1B visa but a valid approved H1B i797. Mexico will NOT allow entry as their rule requires you to have a valid stamped visa in your passport.
Traveling back to USA
USA will allow entry based on approved AP. You may need extra time at the airport/land border as every advance parole entry needs a secondary inspection.
It can take anywhere between 1-3 hours based on the secondary inspection queue at the airport at that time.
With closed loop, they still need to verify if you have valid way to enter the US it you stop in a country which doesn’t have AVR rule applicability.
In many cases, I have heard that they allow even if visa is expired but the day CBP checks, they may be denied entry and then the problem will start.