Using AP to come back
You can keep your H1B status only if you return with a H1B entry visa. Using AP to return, your status is GC pending.
Once you choose to use EAD, you lose your H1B status. When your I485 is denied, you are out of status immediately.