The way that the "Hold the Line" section works is that every person who holds the line has a point value assigned to them in terms of strength. Let's say a non-loyal Mordin, Kasumi, and Tali are the weakest and have a rating of zero. There are three tiers of characters stronger than them, so let's say the strongest ones - Grunt and Zaeed - when loyal, have values of 4. If they were disloyal, they would have values of 3.
What the game does is it takes the mean average value of every single person that you leave to hold the line. If that mean average value is above a certain threshhold - say, 2 - then nobody dies holding the line. If it's between, say, 1 and 2, then one person will die, with priority given first to disloyal people and then to people with the lowest defense threshhold (Mordin will die first in most cases, but Miranda is disloyal in your file so she bites it here).
Since Miranda is disloyal, the only way for her to survive is to leave her behind and pad out the strength of the line as best you can. Send Mordin to escort the ship, bring Kasumi and Tali with you, and the average value of the defenders will be as high as possible. Taking Jack and Jacob could make all the difference. Jack's almost as weak as the bottom four, but Jacob is in the second-highest tier, a certifiable bad-ass.
In order ot make Miranda survive, here is what you need to do:
1. Make sure Mordin is the one who escorts Dr. Chakwas and the rest of the crew back to the ship.
2. Bring Tali and Kasumi with you to fight the Baby Reaper.
If everyone else is loyal, Miranda will survive. If you want, I can go find the actual formula for you, and I'll do the math just to be sure.
Just found out that Zaed isn't loyal --the hard way! Neither is Miranda. I just finished the game. Zaed took a bullet to the chest (shields failed). Miranda died right after the baby reaper battle (you said not to bring her but I didn't listen!). Mordin died trying to hold the line. Grunt and the prisoners all made it back to the ship alive.
I have one save where all of my team survived but since I was dicking around, my ship crew all died. I have another save with a not loyal Zaed and a formerly loyal Miranda. My whole crew is safe, though.
I tried it my way, and it totally failed. Now, oh brave and handsome Khuutra, I come to you. I'm going to restart that whole final mission. Tell me who to bring and which role each member should play. I'll follow your advice to the letter. Also, I'd like for him to live but, if Zaed dies, I don't care. He was kinda annoying.
Garrus leads all fire teams (if you get anyone but Garrus, Jacob, or Miranda to do this, they will die - that's why Zaeed bit it), Legion goes down the pipe to hack the securities, Jack handles shield duties when it's time for a biotic to show up.
Mordin escorts Chakwas and crew back to the ship.
Tali and Kasumi come with you to the finale.
Everyone else holds the line.
That way, the only way anyone is going to die is if you have some more disloyal members you forgot about. This should get them all through clear, no questions asked.
If Legion isn't loyal, get Tali or Kasumi to go down the pipes. Never send a disloyal person to do any of these jobs.
In fact, here
People who can get through the pipe: Kasumi, Tali, Legion (any of these have to be loyal)
People who can lead fireteams: Garrus, Jacob, Miranda (they have to be loyal)
If the person who you pick for either of those jobs is wrong, the tech specialist will be shot while trying to shut the door.
People who can hold the biotic barrier: Jack, Samara/Morinth
They are the only ones. If you choose someone else (or your biotic is disloyal) then one of your squadmates in your party will die when the barrier fairs.
People who should escort Chakwas back to base: Mordin, Tali, Kasumi, Jack (priority given to Mordin, whoever you send on this HAS to be loyal)
People who should come with you to fight the baby Reaper: Whoever from the previous list didn't take Chakwas back to the ship (these two HAVE to be loyal)
Grunt, Zaeed, and Garrus should always hold the line, no matter what. Everyone else should too, if possible.