The G31 P value is intended to set the threshold for analog sensors. The fact that it can be used to debounce noisy digital Z probe inputs is a by-product of the filtering that is applied. A Z probe reading is taken every 2ms and that is passed into an averaging filter. The filer takes the average of the last 8 readings. For an analog Z probe, the reading is whatever the probe returns. For a digital Z probe, it is 1000 when the probe output is active and 0 when it isn't.
The upshot of this is:
Events shorter than 2ms in duration may not be seen
If you use a digital sensor and you set the G31 P parameter to 125 or less, then a single active reading from the probe is sufficient to cause a trigger
If you set the threshold between 126 and 250 then you need two readings out of the last 8 to be active to cause a trigger
The 2ms interval between readings is a hangover from the old code that used the Arduino core, and I'll probably change it to 1ms before the 1.18 release.
HTH David