diff --git a/indra/newview/llimprocessing.cpp b/indra/newview/llimprocessing.cpp
index f6093437bbf7625d2110e877dc2da836273e941b..7150db280ddb0c2bf3f1ac0b3c24adc943aaaa0b 100644
--- a/indra/newview/llimprocessing.cpp
+++ b/indra/newview/llimprocessing.cpp
@@ -493,7 +493,7 @@ void LLIMProcessing::processNewMessage(LLUUID from_id,
     // make sure that we don't have an empty or all-whitespace name
     LLStringUtil::trim(name);
     static const LLCachedControl<bool> sMarkUnnamedObjects(gSavedSettings, "AlchemyChatMarkUnnamedObjects");
-    if (name.empty() && sMarkUnnamedObjects)
+    if (sMarkUnnamedObjects && name.empty())
     {
         name = LLTrans::getString("Unnamed");
     }
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 8fe20e98cb4e46505d44eac3a78838fd5ec9d364..6a45f6d2ad75a01424c1a1065d6bb61d11608055 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -2412,7 +2412,7 @@ void process_chat_from_simulator(LLMessageSystem* msg, void** user_data)
 		// make sure that we don't have an empty or all-whitespace name
 		LLStringUtil::trim(from_name);
 		static const LLCachedControl<bool> sMarkUnnamedObjects(gSavedSettings, "AlchemyChatMarkUnnamedObjects");
-		if (from_name.empty() && sMarkUnnamedObjects)
+		if (sMarkUnnamedObjects && from_name.empty())
 		{
 			from_name = LLTrans::getString("Unnamed");
 		}