Sorry to hear that, hope you're okay.
Ideally each company will pay for the damage for which their driver is liable. Like you said, additional damage may end up totaling the vehicle. Each company owes to put you back to pre-loss condition; it just so happens that "pre-loss" condition for the second company is a vehicle with preexisting damage. You may end up having a bit of additional stress to deal with if the two other companies don't make it easy for you. I'd at least talk to each company and let them answer that question for you before you get too worried about it though. You may end up calling Monky on this one.