If the device is factory reset when it is running the custom firmware, it will come back to the same configuration, as if the custom firmware was just flashed.
If you'd like to go back to the official RutOS build, you'd need to flash an official image via the WebUI. If WebUI is not reachable, there is always a bootloader method for RUT, RUTX, TCR, and TRB2xx devices. For TRB1xx and TRB5xx a different recovery method is used (fastboot), which involves quite a few steps.
Could you let me know your concerns? Are they about not being able to recover the device after a failed build flash?