src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php (line 329)
Replaced the broken bundle-level count with array_sum(array_map('count', $reference_items)), which flattens the bundle-grouped result and counts actual entities. Added a one-line comment explaining why the flatten is needed. This addresses all three reviewer asks (no array_shift/mutation, explanatory comment, simpler than the nested if/elseif).
tests/src/FunctionalJavascript/ComplexWidgetTest.php Added testRemoveButtonWithSingleBundleMultipleEntities() — a regression test that uses the existing multi field (required, single target bundle ief_reference_type), sets allow_new=FALSE / allow_existing=TRUE, creates 3 referenceable nodes, and creates a parent referencing exactly 1. On pre-fix code the Remove button is suppressed (single-bundle count == 1 ⇒ $can_replace_last_reference false ⇒ required field can't drop to zero). On post-fix code it appears.
Closes #3469864