Hello!
I just wanted to chime in here as I have found what causes this issue and I want to publish it to save people from future headaches.
The issue is that the onboard console flash is updated to an OS version that is NEWER than what you have on your HDD and/or recovery flash drive. Even if the flash version is just a day newer than the version you have on the drive, it will throw this error and leave you in an endless error loop not allowing you to do anything.
To fix this, go to to the Xbox Support website and download the current newest OSU1 files and reformat your hard drive using those new files, and put the new $SystemUpdate folder on your recovery flash drive to boot into. Once you’ve done this, go ahead and perform the offline system update and then factory reset as you normally would it will work smoothly and you’ll be back up and running!
Hope I helped! I spent hours trying to figure this out, and hopefully now other folks won’t have to