Disclaimer: This post is for educational purposes only. Always consult with your school's international office or an immigration lawyer to discuss your specific situation and ensure you're making the right decisions for your visa status.
The source of this is linked at the bottom
For F-1 visa holders, understanding the complexities of travel during OPT (Optional Practical Training) and the H-1B application process is crucial to avoid complications. Here's a detailed guide to help you navigate these important decisions:
OPT Applied and Pending:
You can travel, but it is NOT recommended.
OPT Approved:
You CAN travel if:
You have a valid passport and F-1 visa.
You have proof of employment/training.
Your I-20 is endorsed for travel.
Note: Time spent outside the USA during OPT counts towards your maximum permitted days of unemployment.
If OPT is Approved But You Don’t Have a Job:
Traveling without a job offer is NOT recommended. CBP may question your purpose of re-entry, and you could face challenges proving that you are maintaining your status. Additionally, time outside the U.S. without employment still counts towards your 90-day unemployment limit during OPT.
If OPT is Approved But You Get Laid Off During Travel:
This situation can be particularly challenging. If you are laid off while outside the U.S., you may face difficulties re-entering. Without a job, your OPT status is jeopardized, and you will need to find new employment within the 90-day unemployment period. If you cannot secure a new job, re-entry might be denied as you could be considered out of status.
STEM OPT Applied and First Year OPT Still Valid:
You can travel if:
STEM OPT Applied and First Year OPT Expired:
Do NOT travel until STEM OPT is approved.
STEM OPT Approved:
You can travel if:
Travel Before H-1B Lottery is Filed:
You can travel, but ensure you meet the requirements for OPT or STEM OPT travel.
Travel After Lottery is Filed or Selected, Before H-1B Petition is Filed:
You can travel, but be sure to be back in the USA when the H-1B petition is filed.
Travel While H-1B Petition is Pending:
NOT recommended as it can create serious problems.
Travel After H-1B Petition is Approved:
Additional Considerations for OPT Students During Holidays:
Traveling during these critical times can be risky and may lead to unintended consequences.

Source: https://www.immigration.com/blogs/f-1-students-travel-during-opt-or-h-1b-process