To answer this question, Let's look at the rules, PHB p.189:
Combat Step by Step
1. Determine surprise. The DM determines whether anyone
involved in the combat encounter is surprised.
2. Establish positions. The DM decides where all the
characters and monsters are located. Given the
adventurers’ marching order or their stated positions in
the room or other location, the DM figures out where the
adversaries are—how far away and in what direction.
3. Roll initiative. Everyone involved in the combat encounter
rolls initiative, determining the order of combatants’ turns.
4. Take turns. Each participant in the battle takes a turn in
initiative order.
5. Begin the next round. When everyone involved in the
combat has had a turn, the round ends. Repeat step 4 until
the fighting stops.
So, you've done this and fought a few rounds between group A and group B when group C comes along.
1. Determine surprise.
No one in either A or B can be surprised because they are aware of a threat (A is aware of B and vice-versa). They may or may not be aware of C but that doesn't matter. On the other hand, members of C can be surprised depending on the circumstances, however, it is unlikely that all members of A and all members of B are "trying to be stealthy" so opportunities for C to be surprised would be rare.
Notwithstanding, it may be reasonable in some circumstances to allow the members of C to begin the encounter hidden; in which case they make a Dexterity (Stealth) roll and follow the rules for the Hide action. For example, if C is stealthily advancing towards the sounds of battle or C takes the opportunity to hide and wait for the battle to come to them.
2. Establish positions.
The positions of A & B are already known so you just need to work out where C is. Essentially this is no different from what you did with A & B in the first place. The location of C will depend on local geography and if C went to the battle or the battle went to C.
3. Roll initiative.
The rule here is really simple:
3. Roll initiative. Everyone involved in the combat encounter
rolls initiative, determining the order of combatants’ turns.
Well A & B have already done this so C just does this and slots in wherever they fit.
You do this when C becomes (or can choose to become) involved in the combat. As a rule, do this when C is close enough to the battle that they could intervene (or be drawn in) on any creature's turn (in group A, B or C). On a big flat plain this would be when a single turn could put a member of C within range of A or B's ranged attacks or vice-versa. Ina dungeon, this would be when a single turn could put C in the line of sight of A or B (e.g. by opening a door, moving down a corridor, entering an illuminated area etc.).
4. Take turns.
C is now slotted in and they each act when their turn rolls around.
If the members of C wish to intervene simultaneously then they can use the Ready action to say, for example, "I cast my spell/use my bow etc. when the last member of team C takes their action."
If C is hidden, then only members of A & B who perceive them can act against them.
5. Begin the next round.
And we're done. You now have the big battle your heart desired.