Harry can choose groups of friends in 3 main scenarios:
1) Ron is included, but not Hermione.
2) Hermione is included, but not Ron.
3) Neither Ron nor Hermione is included.
We'll count the number of valid groups for each scenario.
Case 1: Ron is included, but not Hermione
If Ron is included, then Hermione cannot be part of the group. The remaining friends to consider are: {Hagrid,Luna,Neville,Fred,George}(5 people)
Harry can choose any subset of these 5 friends (including no one), giving us
5C0+5C1+5C2+5C3+5C4+5C5= 1+5+10+10+5+1=32 groups (we'll use reasoning rather than formulas: for each friend, Harry either includes them or doesn't, leading to all possible subsets).
Case 2: Hermione is included, but not Ron
If Hermione is included, then Ron cannot be part of the group. The remaining friends to consider are:
Just as in Case 1, Harry can choose any subset of these 5 friends. Again, there are:
{Hagrid,Luna,Neville,Fred,George}(5 people)
Harry can choose any subset of these 5 friends (including no one), giving us
5C0+5C1+5C2+5C3+5C4+5C5= 1+5+10+10+5+1=32 groups
4. Case 3: Neither Ron nor Hermione is included
If neither Ron nor Hermione is included, the remaining friends are
{Hagrid,Luna,Neville,Fred,George}(5 people). Once again, Harry can choose any subset of these 5 friends. This gives: 32 valid groups.
5. Total valid groups
Add up the groups from all three cases:
32+32+32=96