All I know, assuming a “market” rate of 5%, is that your friend will save $93,238.37 if he sells the home at the optimum time (185 months from now). If he has to pay back the $40K at that time, he’ll still be up over $50K. Even in just five years, he’ll be up $27.5K (after paying the 40). This is on top of the money he already took out of the house. Somebody eats this in the long run and that kind of sucks for everybody else, whether your friend is a nice guy or not.
I’m not saying that the bank necessarily has a better choice, because while it’s not all gravy, any alternative cuts into their income (and profit) as well. That is, they will never get what the original loan terms laid out. If they foreclose, at peak, they could earn a few more thousand dollars, but that’s subject to timing and variability as well. Hell, if he goes to term (40 years) on the loan mod, they’ll be up $1,473.47 over the original loan term!
So basically, at this level, it’s something of a flip of the coin, loan mod vs. foreclosure. You’re friend should consider himself a lucky bastard. At least on this front.