Whether to tip (and how much) comes down to a few key factors.