We are learning from Case Studies in Business Ethics by the late Rabbi Dr. Aaron Levine z"l professor of economics at Yeshiva University.
Question: if an unexpected visitor comes by without an appointment is it permissible to lie and say you are busy or have someone say you are not present?
Rabbi Shlomo Zalman Aurbach (Israel 1910-1995) dealt with this question. The gemara cites a story of a particular town taht held an unusually high standard of integrity. Rav Tavut moved to the town but was eventually banished for excactly this case. An unannaunced woman came to see Rav Tavut's wife and Rav Tavut. She was busy with personal matters so rav Tavut lied and said she was not home. When the lie was eventually discovered the people banished Rav Tavut.
Rav Shlomo Zalman Aurbauch ruled that the standards of that town were beyond the letter and not required in general society. The conduct of Rav Tavut would have normally been regarded as permissible.
If K knocks on D's door without an appointment, D is under no obligation to see him. Moreover, D's right to privacy puts him under no duty to inform K what he is doing at that time or why he does not wish to see him.
With the aim of avoiding friction with K, it is permissible for D to inform K through another person that he is not home. This is considered a permissible lie and is an application of the principle of darkei shalom - fostering peace.