Short trip to Mexico when COS is pending

Currently, I am on F1 STEM OPT which is valid till 2023. I am planning to do a COS to H4 soon.
Can I go on a 7-days trip to Mexico and return back to the US while my COS application will be in progress? Will my application be invalidated?

If you leave the US while your COS application is pending, it will get denied so apply COS after coming back.