I would go about this slightly differently.
You have three separate tasks; the first is to identify who is the leader, the second is to determine the level of the leader, the third is to ensure that the new party member is at the level of the leader.
This needs to be done with conditionals, and so is slightly tedious.
Conditional check, using the 'script' option, and this needs to be done for all possible leaders
Code:
$game_party.leader == $game_actors[1]
In the 'else' branch, another conditional, this time for actors[2] and so on for all actors.
Having got the basic structure, you now need to establish the level of the leader, so inside each individual part of the conditional, you need to call up the actor's level with a variable, use that variable to set the new party member's level - and then reduce that by one. Why? Because the new party member will have one level anyway, and if you don't they will come in at a higher level than the hero.
Here is a screen shot of such a check, though only illustrating what you do for actor one. Just repeat those commands for all possible actors.
View attachment 146129