How to know whether to add latent heat when calculating final temperature?
It is less obvious than you seem to assume (say, if water cup in your example were already at $0^\circ$C, then the ice would not melt), but still pretty obvious.

The rule of thumb is:


Assume there is no phase change.
Calculate the final temperature.
Check whether there is a phase change in any of the substances involved as they go from starting to final temperature.
If no, we are done. If yes, assume there is a phase change and go back to step 2.