I think I would be upset if I was laid off but those on medical or baby leave were specifically given a pass. It kind of feels like a slap on the face for those whom are unable to have kids.
Layoffs should be focused on performance, cost of salary, team business utility, etc.
That said, if layoffs disproportionately hit those on that are on medical leave, that would be pretty cruel.
Moreover, I think those laid off during leave should be given additional severance due to the incredible imposition.
Everywhere I've worked has stipulated that leave, sabbaticals, etc. were still subject to layoffs.