I was wondering if it is better to heal the one closest to death.
imho make more sense to me to heal the 3/4 that miss just 1 hp to death.
but if you set up the AI algorithm that way and you have a monster with 10 max HP that has 6 damage (leaving them with 4 HP), and a monster that has an undamaged monster with 3 HP, the heal would be wasted on the 3 HP, since it has fewer HP remaining.
That is why the rules state that the in-range monster that has taken the most damage (or has "lost the most hit points") is the one that is healed.
See page 31 of the rulebook.