When I flash patched AP.tar, I get "error verifying vbmeta: HASH MISMATCH" error. I followed the official instructions for installing magisk.
I also tried flashing patched boot.img, but I get another error saying that only official firmware is allowed to be installed.
I never installed magisk this way, so I don't know if this procedure worked on previous Android versions (or if I'm even doing it right considering it's Samsung...).