The philosophy of lying is quite interesting. I like to say that a lie is truth with an expiration date. If you only knew the lie, and it never was "corrected", to you it would only be the truth. If you were a brain in a vat, and you never discovered you were a brain in a vat, then to you _your truth_ is that you are not a brain in a vat.
Because lying is a function of time (duration, expiration), there is also a relevant short-term and long-term factor. We tend to lie less to people we are in it for the long-term with because there is a greater likelihood the lie "expires". We lie more to strangers because we will never see them again and the lie never expires - the lie _is_ the truth from their perspective.
There also exist "factual truths" and "emotional truths". Factual truths, as the OP discusses, are invariant over time (for the most part, assuming we are omniscient). Logical people love factual truths. Emotional people hate them. Emotional truths vary over time as a function of one's emotional state ("it feels true to me!"). It is not always prudent to tell the factual truth when someone is in their worst or best possible emotional state. Generally speaking, it is prudent to adapt to the situation. If you are in a long-term situation (a repeating pattern), stick to the invariant truth. If you are sensitive to people's emotional states, tolerating some variable truth can be an invaluable social lubricant. I often find that programmers (as logicians) compress eveything into invariants, which encourages a non-negotiable adherence to invariant truth, but this can equally isolate them to the rest of the world which does not operate exclusively with invariants. Programmers say "it is simply the case" while everyone else says "it depends."
Finally, lying creates and magnifies divergent realities between the sender and receiver. At first glance, this is not so problematic - _everyone_ occupies divergent realities - we are different individuals after all. We want to create convergent realities with those with whom we collaborate (a non-zero-sum game) and divergent realities with those who may defect (a zero-sum game). Case in point, we mislead and misdirect the enemy during times of war. All animals do this. It is for this reason lying is often associated with self-interest: we lie (create a divergent reality) to privilege our own interests. If we were transparent about our interests, we would simply create a convergent reality (i.e. tell the truth). Often, we lie because we want to have our cake and eat it too ("I can go to this party AND comfort my parents in telling them I am staying home"). Sometimes, we lie because we are truly acting in the best interests of someone else (a compassionate lie), but it can be hard to make the case that "they really didn't want to know" (if so, why did they ask?) and that you are a better modeler of their preferences than they are (why not ask them directly?). Compassionate lies exist, but they are far less common than self-interested lies disguised as compassionate ones.
As a general heuristic, I recommend always telling the factual truth, but possessing the capability to recognize, understand and commuicate emotional truths for the right situations.