I had previously considered answering your original post with the same advice as Mauam, but held back because I wasn't certain that this is the problem. In a lot of cases, with this phone, where bootloops occur after flashing, the problem is related to encryption, and formatting the data partition removes encryption and solves the problem, at the expense of losing data, if you didn't back it up previously.
My understanding is this.
Flashing over MIUI or a MIUI based custom ROM, you must format data, because MIUI encryption is modified from stock AOSP encryption. (This isn't unusual and many phone manufactures modify the standard AOSP encryption). If you don't format data when flashing you will find that the phone remains encrypted, but the encryption 'flag' is deleted, causing the system (and TWRP) to believe the phone is unencrypted and so unable to read any data because the data is actually encrypted.
Ordinarily, flashing over AOSP ROMs, the encryption flag will remain set and so booting into a new ROM, it recognises the phone is encrypted and prompt for the PIN (or whatever lockscreen security was set).
However this isn't always the case. I personally, in the early days of this phone, had it happen to me where flashing one AOSP ROM over another had caused the phone to boot only into TWRP. Formatting data has then fixed the issue. I have never yet found any answer as to why this sometimes, seemingly randomly, happens. This is why you will see it advised that it's best to remove all lockscreen security before any flashing.
Sorry for the long reply.
So to get to your case.
It certainly sounds like a typical case where your problem is caused by encryption. i.e. The phone is physically encrypted, but the encryption 'flag' is unset, causing the system to not 'know' that it is encrypted.
Formatting data fixes this because it unencrypts the phone.
However the circumstances of your case, to me, aren't typical of the usual cases of this problem, hence I wasn't fully confident that it may be the problem. The easiest way to determine this issue is when you boot into TWRP. With this problem TWRP fails to ask for the unlock PIN (etc.) and so browsing the file system you see all the folders have garbage unintelligible file filenames, because TWRP has not unencrypted the filesystem.
When this happens you can be confident that formatting the data partition will fix the problem.
As far as TWRP backups are concerned, that's a different kettle of fish.
It may be caused by encryption (again temporarily removing lockscreen security, and therefore encryption, is recommended before making a backup). It may be caused by dm-verity and how you backed up various partitions.o You need to make sure that partitions protected by dm-verirty are backed-up using the partition image option, which do a full bitwise perfect copy of the partition instead of just backing up the data in that partition.
It may also be caused if you have some apps configured so that they have multiple installations to allow multiple accounts 'side by side', e.g. Normally used to have social media apps running with multiple accounts without needing to login and out of each account.