It doesn't have too though, if you create a join link you could also advertise the code to other participants. When the new member joins via this invitation link, the code is recognized by everyone.
(I've been downvoted for saying that, but the solution works)
(a) it means each code can only be redeemed once, which is a bit of a usability hit
(b) it still doesn't stop a malicious server, which can try to MITM the group join and proxy messages to the client.
(I've been downvoted for saying that, but the solution works)