Then they should have just sent the majority of the Dothraki south to the Riverlands to wait until after the battle.IMHO that premise is wrong given the nature of the AOD so it skews the rest of your analysis. Start with the objective and work backwards. The objective is to kill the NK because that is the only known way to destroy the AOD. The NK's objective is to kill Bran and the rest of the living.
The chosen strategy then is to lure the NK into the open. Jamie already noted that the NK will then not expose himself and Bran corrected him. He knows from history under what conditions that will happen. They are not defending the castle as much as defending Bran. They know that the castle walls will be breached for this to happen.
Going into the battle Jon/Dany had three options to kill the NK. Keep in mind that nothing short of killing the NK would win the battle. Nothing. Battlefield delaying actions in and of themselves were useless away from the castle so they:
1. Used dragons to protect ground forces while trying to kill the NK with dragon fire or in a dragon battle.
2. Used the Dothraki to charge hoping for a WW kill that would open a path to the NK.
3. Kept the forces close to delay the AOD only when it mattered. To do this, the Unsullied staged an orderly retreat with a rear guard in a Dunkirk fashion. The trench was a temporary measure because the AOD could have waited until the fuel was exhausted without changing the outcome. When the AOD got to the trench is when the only delaying actions matter to the strategy.
And it would have had no effect on the timeline of the breaching of the gates, either.