macbook pro stuck in boot loop - recovery mode and safe mode not working

I was able to fix this by using a bootable Ubuntu usb to boot my system, and choosing the option for formatting the SSD. Then after installing Ubuntu I was able to use a bootable MacOS usb drive to reinstall MacOS Mojave successfully. As mentioned above, absolutely nothing was working including the disk utility, internet recovery, or using a bootable MacOS USB drive. Everything was causing the system to freeze.