I'm running the latest 12.5.2 Stable on my Mi 9T since it was released (and an earlier Stable prior to that, and Weeklies for who knows how long), and never had that problem
With new Magisk and specially Zygisk, Shamiko it rakes me two minutes or so to boot but if I disable Magisk it boots fine
(Ok, it's not that fast and responsive as MIUi 10/11 used to be, but that's the price of upgrading MIUI to an old phone)
Factory reset should help
At least (without loosing your data and settings), try first:
- In TWRP, Wipe Dalwik and Cache
- also in TWRP, File Manager, navigate to /data/system/package_cache and delete that (sub)folder
If needed, google to find how to use advance features in TWRP