When one layer is selected, and you shift+click, it normally selects all layers between the originally selected one and the Shift+Clicked one. However, if part of that selection includes a layer group with a mask, and that group is expanded/open, the selection in the end includes *all* underlying layers (not just the ones in the range between the original selection and shift+clicked one)