I had this problem with a few phones I repaired.
If you are using a non OEM sensor with a non OEM screen, make two small scratch holes in the paint on the screen where the proximity sensor sits. You should clearly see light through the scratches. Always glue the original sensor holder into the correct position.
If you are using a working OEM sensor with a non OEM screen, darken the inside of the glass where the sensor sits with a black sharpie. I have noticed that the OEM sensors are prone to faults once removed so I find it better to use non OEM sensors as they are far less sensitive and cost very little.
I have not had a problem since adapting this method on 100+ repairs