Questions about matchmaking like in League of Legends (LOL)

Options

Hi, I want to make a matchmaking system like in lol.

this is scenario:

there are two room type, for waiting and matchmaking. room for waiting is not visible, so only invited friends can join. (I made it using another service) and room for matchmaking is visible to enable other users can join together.

A and B are friends and they are in the same 'waiting' room. A is master.

C and D are also friends and they are in the same 'waiting' room. C is master.

when A starts matchmaking (only master can start to find match), A and B create a new 'matchmaking' room becuase there's no room for matchmaking (I used joinRandomOrCreateRoom), and waiting until this room becomes full. (only when fully joined, game starts.)

After that, C starts matchmaking and automatically C and D join the room that A and B are already in.

But we need total 5 players to start game. So they should wait for one more player.

Problem:

In this scenario, if C cancels matchmaking, A,B,C,D must not be in the same room. What can I solve this?

My solutions:

C try to make a new 'waiting' room again and D follows C. And for this, also need to know which one was master before because C must be master again.

Is this a good solution? or Is there any way to make matchmaking system while users are in lobby? maybe using expectedUsers of room? If you have better idea, please let me know. Thank you.