I see. You were legal to work during the H1 pending even if your H1 is denied later. Your I-485 and your status are absolutely safe.