The shortcut Shift+LMB on a disabled layer mask enables it, and disables it if the layer mask is enabled. Enabling and disabling a layer mask using this shortcut records a new step in the history as expected. "Disable Layer Mask" and "Enable Layer Mask".
A single LMB on the layer mask, without the Shift pressed, enables it as well. But in this case, not using Shift but only the left mouse button, the history doesn't record "Enable Layer Mask".
So, we have the following:
Shift+LMB: it toggles the mask on/off - record a new step in the history LMB: it turns the mask on - does NOT record a new step in the history
I need the history to ALWAYS record when a mask toggles on/off.