diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 5dd03783ade1b7490aff55e14a8f3a90f7d232a3..c865dcf9a3ff98ddf87cea65ac6f9bfe4d21a5e7 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -526,7 +526,8 @@ bool LLIMModel::LLIMSession::isOtherParticipantAvaline()
 
 void LLIMModel::LLIMSession::onAvatarNameCache(const LLUUID& avatar_id, const LLAvatarName& av_name)
 {
-	mHistoryFileName = av_name.mUsername;
+	// if username is empty, display names isn't enabled, use the display name
+	mHistoryFileName = av_name.mUsername.empty() ? av_name.mDisplayName : av_name.mUsername;
 }
 
 void LLIMModel::LLIMSession::buildHistoryFileName()