For the problem with magisk. You can start sideload mode in twrp, connect the phone to PC and run "adb sideload magisk.apk" or the magisk.zip (the ending doesn't matter, apks are literally just zip files with different name)
Why do you need magisk tho, if you want to reflash anyways?