The question

I graduated and am searching for a job with my F1 STEM OPT EAD. My spouse is in H1B with an approved I140. I'm looking to become a dependent on my spouse's visa. From a perspective of continued stay in the US, would there be an issue if my H4 approval arrives after my OPT expires? What happens if I accumulate 90 days of unemployment before my H4 is approved, would I have to leave the US?