Low coherence masking before phase unwrapping

Hello everyone.
I’m trying to run phase unwrapping on a “clean” data, after the application of a coherence mask. As I already read in some topics here, a way to mask low coherence pixel is to right click on the Phase band, select Properties, then in Valid-Pixel expression box put the expression: if coherence product with EXACT name > 0.5 (I need this mask) then Phase product name else 0. Then I click on Convert band and I obtain a interferogram with black areas where low coherence pixels are located. But when I perform Phase Unwrapping, the product that I obtain is the same as without mask.
Is there something that I’m doing wrong? Am I missing some steps? And is there a way to build a coherence mask on Python (something like an array)?
Thanks in advance to who will help