Multi selection of grouped rows

I have a table of files which are grouped by file type:

enter image description here

The user can select rows by clicking. If a group header is selected (4 XLSX files), then all XLSX files will be selected. Multiple rows can be selected by Ctrl-clicking or Shift-clicking.

What if the user selects multiple lines with Shift-click and one of the lines is a group header. Should this cause to select the whole group, too, or deselect that header instead.

  1. A or B?

  2. The group headers can be collapsed. What should happen if a collapsed group is selected?

enter image description here