I failed to install Magisk and now I can't get out of TWRP
If you don't need the data download the stock fastboot rom for your device and flash it.
From your comments above it looks like you've already wiped your data.
So I would suggest that you download the stock fastboot rom. Do a clean all flash. Don't do the clean all and lock flash, as it will lock your phone.
Once it's finished, you can flash twrp but don't try to disable file based encryption and then try flashing whatever other rom you were trying