The exact wording of the ICD-10 guidelines, Section IV.J, is as follows:
Code all documented conditions that coexist at the time of the encounter/visit, and require or affect patient care treatment or management. Do not code conditions that were previously treated and no longer exist. However, history codes (categories Z80- Z87) may be used as secondary codes if the historical condition or family history has an impact on current care or influences treatment.
Whether or not a particular diagnosis 'affects patient care' or 'influences treatment', however, is often going to be subject to interpretation based on the provider's specific documentation. Providers generally must consider all existing conditions when evaluating a patient, whether they treat the condition or not, but their documentation may not always reflect this.