I have been struggling with a similar issue where the sphere detects everything but the specified layer.
This did not really work for me, but I heard it work for others: Put a Tilde character (~) in front of "playerMask". This would become "~playerMask". This will reverse the operation to ignore everything but that layer. This is because it ignores the specified layer, instead of including it.
If that does not work, as for me, I heard there could be a weird Unity feature that makes the method use the collision matrix despite your specific layer. This could present issues. For my issue, I did not use the layer parameter at all and instead checked it within a selection statement, e.g. "if(gameObject.layer == playerMask) {"
Hopefully this helps!
Reference: https://discussions.unity.com/t/solved-physics-overlapsphere-does-not-see-the-needed-layer/776021 User: Kurt-Dekker