It would appear you are publishing a Feature service to AGOL? Currently, you cannot publish feature services with group layers (all layers will be ungrouped and en masse).
However, with the new Map Viewer, you can now re-group your layers on the web side (Portal and AGOL), and the groups will be honoured if you author a web app using Experience builder or Instant Apps.
When you remember it working with ArcMap, perhaps you were publishing Map Image Services to Portal? These support group layers direct from ArcMap/Pro, as these are "served" on the ArcGIS Server tier, not in Portal or AGOL directly.
David
..Maps with no limits..