Perhaps, you may try as shown below, formulas used applicable to MS365 users only

• Formula used in cell C1
=LET(array,FILTER(A1:B7,ISNUMBER(B1:B7*1)*(B1:B7<>"")),
id,INDEX(array,,2),
u,UNIQUE(id),
sumf,BYROW(u,LAMBDA(x,SUMIFS(A1:A7,B1:B7,x))),
FILTER(CHOOSE({1,2},sumf,u),sumf=MIN(sumf)))
And when writing this formula if you have enabled the Beta Channel from Office Insiders then you can use the HSTACK() in place of CHOOSE()

• Formula used in cell C1
=LET(array,FILTER(A1:B7,ISNUMBER(B1:B7*1)*(B1:B7<>"")),
id,INDEX(array,,2),
u,UNIQUE(id),
sumf,BYROW(u,LAMBDA(x,SUMIFS(A1:A7,B1:B7,x))),
FILTER(HSTACK(sumf,u),sumf=MIN(sumf)))
Following Excel functions used to derive the Output,
LET() -- Used to assigns names to calculation results,
FILTER() -- Used twice, in the beginning to create an array of
results which excludes the non numeric as well as the blanks, and
at last to get the required output,
ISNUMBER() -- Used within FILTER() to get numeric values, returns
TRUE,
INDEX() -- Used to extract the ID's from the array,
UNIQUE() -- Used to get the unique values from the id,
BYROW() & LAMBDA()-- Used to apply a LAMBDA() to each row and to
return an array of the sum of unique values,
SUMIFS() -- Used with in LAMBDA() to get the sum
CHOOSE() / HSTACK() -- Used to return the array formed by
appending each of the array arguments in a column-wise fashion,
MIN() -- Used to return the min of sum values.
EDIT

• Formula used in cell B13
=TRANSPOSE(LET(array,FILTER($A$1:B11,(LEFT(B1:B11)="O")*(B1:B11<>"")),
id,INDEX(array,,COLUMN(B1)),
u,UNIQUE(id),
sumf,BYROW(u,LAMBDA(x,SUMIFS($A$1:$A$11,B1:B11,x))),
FILTER(HSTACK(sumf,u),sumf=MIN(sumf))))
Or,
=TRANSPOSE(LET(array,FILTER($A$1:B11,(LEFT(B1:B11)="O")*(B1:B11<>"")),
id,INDEX(array,,COLUMN(B1)),
u,UNIQUE(id),
sumf,BYROW(u,LAMBDA(x,SUMIFS($A$1:$A$11,B1:B11,x))),
FILTER(CHOOSE({1,2},sumf,u),sumf=MIN(sumf))))
And now drag right for the rest!