function addSubtotals(rowColumnTree, formatters, showSubtotalsByColumn) {
  // For top-level items we want to show subtotal even if they have only one child
  // Except the case when top-level items have flat structure
  // (meaning all of the items have just one child)
  // If top-level items are flat, subtotals will just repeat their corresponding row
  // https://github.com/metabase/metabase/issues/15211
  // https://github.com/metabase/metabase/pull/16566
  const notFlat = rowColumnTree.some(item => item.children.length > 1);

  return rowColumnTree.flatMap(item =>
    addSubtotal(item, formatters, showSubtotalsByColumn, {
      shouldShowSubtotal: notFlat || item.children.length > 1,
    }),
  );
}
// We also mark nodes with `hasSubtotal` to display collapsing UI
We also mark nodes with `hasSubtotal` to display collapsing UI
We also mark nodes with ` hasSubtotal ` to display collapsing UI
function addSubtotals(rowColumnTree, formatters, showSubtotalsByColumn) {
  const notFlat = rowColumnTree.some(item => item.children.length > 1);
  return rowColumnTree.flatMap(item =>
    addSubtotal(item, formatters, showSubtotalsByColumn, {
      shouldShowSubtotal: notFlat || item.children.length > 1,
    }),
  );
}
function addSubtotals ( rowColumnTree , formatters , showSubtotalsByColumn ) { const notFlat = rowColumnTree . some ( item => item . children . length > 1 ) ; return rowColumnTree . flatMap ( item => addSubtotal ( item , formatters , showSubtotalsByColumn , { shouldShowSubtotal : notFlat || item . children . length > 1 , } ) , ) ; }
We also mark nodes with `hasSubtotal` to display collapsing UI
We also mark nodes with ` hasSubtotal ` to display collapsing UI
// For top-level items we want to show subtotal even if they have only one child // Except the case when top-level items have flat structure // (meaning all of the items have just one child) // If top-level items are flat, subtotals will just repeat their corresponding row // https://github.com/metabase/metabase/issues/15211 // https://github.com/metabase/metabase/pull/16566