What happens if the H1B expires but the I485 has not yet been approved?

my wife got her H1B in 2015, this was extended in 2018 and is valid until October 2021.
Her employer would like to sponsor a green card for my wife. At the moment her employer has published her job as a job offer because he has to prove that there is no American for the job. Next step: PERM.

My question at the moment is rather hypothetical: How would the legal status be if the I140 was approved but the I485 is still being processed and the H1B expires during this period? Would she have to leave the country until the I485 was approved ?

Her employer can keep renewing her non immigrant status(H1) using either her approved labor(after one year of its filing) OR her approved i140 beyond 4 yeras till she gets her immigrant visa (green card) approved.