The culprit here is definitely the MIUI8. I have had the same problem recently, and read somewhere that people have had this problem mainly with MIUI8, so I tried various versions and found out that older MIUI7 versions with Android 4.4 wrk fine. Then I tried several MIUI8 versions, including 8.1.3, 8.1.6, 8.6.0 - all had the same problem - The refocus tion was in the camera, it just didn't work when in gallery. So I installed the MIUI7 version 6.3.17, which is already based on Androin 6.0.1 and voila, it works again. It looks almost exactly as the MIUI 8 versions and works fine. It seems that the MIUI8 version has some bug when it comes to the refocus and 120 fps recording functions.
P.S.: since then I got a message that it is supposed to have worked with the MIUI8.0.2 too, so I'll have to test that yet, but for me the safest bet so far is MIUI7 Global version 6.3.17. Try installing this through fastboot with wiping the data and let me know.