So I can tell you that you don't need to do a factory reset in order to get root back. I've made a few errors myself as of lately including forgetting to unhide magisk. Can't remember specifically what I did but I did lose root and used Pixel Flasher to dirty flash the latest factory image over the current slot I was using and it worked flawlessly. It went right back to where I was prior to losing root, even kept all my modules enabled and my settings intact. So just patch the bootloader, flash the latest image (or whatever one you were using) and you should be good to go.