diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h
index 6675edc4590ca500e4a59dde003044ab04906b86..ec486dd6321446ad260b7618703bfd494e818cb0 100644
--- a/indra/llui/llfloater.h
+++ b/indra/llui/llfloater.h
@@ -366,7 +366,7 @@ class LLFloater : public LLPanel, public LLInstanceTracker<LLFloater>
 	virtual void    setDocked(bool docked, bool pop_on_undock = true);
 
 	virtual void    setTornOff(bool torn_off) { mTornOff = torn_off; }
-	bool isTornOff() {return mTornOff;}
+	bool isTornOff() const {return mTornOff;}
 	void setOpenPositioning(LLFloaterEnums::EOpenPositioning pos) {mPositioning = pos;}
 
 
diff --git a/indra/newview/llfloaterimnearbychat.cpp b/indra/newview/llfloaterimnearbychat.cpp
index 200f2408c8adee003c6c0953e84e1d592f9eb581..6d2dc6d4b13f4353e7514016a44a96d2a19428ca 100644
--- a/indra/newview/llfloaterimnearbychat.cpp
+++ b/indra/newview/llfloaterimnearbychat.cpp
@@ -374,7 +374,7 @@ void LLFloaterIMNearbyChat::show()
 		openFloater(getKey());
 }
 
-bool LLFloaterIMNearbyChat::isChatVisible() const
+bool LLFloaterIMNearbyChat::isMessagePanelVisible() const
 {
 	bool isVisible = false;
 	LLFloaterIMContainer* im_box = LLFloaterIMContainer::getInstance();
@@ -383,9 +383,25 @@ bool LLFloaterIMNearbyChat::isChatVisible() const
 	if (im_box != NULL)
 	{
 		isVisible =
-				isChatMultiTab() && gSavedPerAccountSettings.getBOOL("NearbyChatIsNotTornOff")?
-						im_box->getVisible() && !im_box->isMinimized() :
-						getVisible() && !isMinimized();
+				isChatMultiTab() && !isTornOff() ?
+			im_box->isShown() && im_box->getSelectedSession().isNull() && !im_box->isMessagesPaneCollapsed() :
+			isShown() && isMessagePaneExpanded();
+	}
+
+	return isVisible;
+}
+
+bool LLFloaterIMNearbyChat::isChatVisible() const
+{
+	bool isVisible = false;
+	LLFloaterIMContainer* im_box = LLFloaterIMContainer::getInstance();
+	// Is the IM floater container ever null?
+	llassert(im_box != NULL);
+	if (im_box)
+	{
+		isVisible = !isTornOff() ?
+			im_box->isShown() && im_box->getSelectedSession().isNull() :
+			isShown();
 	}
 
 	return isVisible;
diff --git a/indra/newview/llfloaterimnearbychat.h b/indra/newview/llfloaterimnearbychat.h
index ba94c7fc083a0935584e0a9a44954b6832eb80e9..969c4ec0b88fa9c4125a27fa67135132c76c6e20 100644
--- a/indra/newview/llfloaterimnearbychat.h
+++ b/indra/newview/llfloaterimnearbychat.h
@@ -64,6 +64,7 @@ class LLFloaterIMNearbyChat final
 	void removeScreenChat();
 
 	void show();
+	bool isMessagePanelVisible() const;
 	bool isChatVisible() const;
 
 	/** @param archive true - to save a message to the chat history log */
diff --git a/indra/newview/llfloaterimnearbychathandler.cpp b/indra/newview/llfloaterimnearbychathandler.cpp
index 6753c03704164cd7a348f19a1d5e3e6c04b7b6cd..bc1b5a9910b4d110a42564beb30084c862acd88e 100644
--- a/indra/newview/llfloaterimnearbychathandler.cpp
+++ b/indra/newview/llfloaterimnearbychathandler.cpp
@@ -603,9 +603,12 @@ void LLFloaterIMNearbyChatHandler::processChat(const LLChat& chat_msg,
 			&& gSavedSettings.getBOOL("UseChatBubbles") )
 		|| mChannel.isDead()
 		|| !mChannel.get()->getShowToasts() )
-		&& nearby_chat->isMessagePaneExpanded())
-		// to prevent toasts in Do Not Disturb mode
-		return;//no need in toast if chat is visible or if bubble chat is enabled
+		|| nearby_chat->isMessagePanelVisible())
+		// <RYE>
+		// no need to toast if bubble chat is enabled or nearby chat toasts are disabled
+		// or if in Do Not Disturb mode
+		// or if conversation is visible and selected and not collapsed
+		return;
 
 	// arrange a channel on a screen
 	if(!mChannel.get()->getVisible())
@@ -644,37 +647,38 @@ void LLFloaterIMNearbyChatHandler::processChat(const LLChat& chat_msg,
 			toast_msg = chat_msg.mText;
 		}
 
-		bool chat_overlaps = false;
-		if(nearby_chat->getChatHistory())
-		{
-			LLRect chat_rect = nearby_chat->getChatHistory()->calcScreenRect();
-			for (std::list<LLView*>::const_iterator child_iter = gFloaterView->getChildList()->begin();
-				 child_iter != gFloaterView->getChildList()->end(); ++child_iter)
-			{
-				LLView *view = *child_iter;
-				const LLRect& rect = view->getRect();
-				if(view->isInVisibleChain() && (rect.overlaps(chat_rect)))
-				{
-					if(!nearby_chat->getChatHistory()->hasAncestor(view))
-					{
-						chat_overlaps = true;
-					}
-					break;
-				}
-			}
-		}
-		//Don't show nearby toast, if conversation is visible and selected
-		if ((nearby_chat->hasFocus()) ||
-			(LLFloater::isVisible(nearby_chat) && nearby_chat->isTornOff() && !nearby_chat->isMinimized()) ||
-		    ((im_box->getSelectedSession().isNull() && !chat_overlaps &&
-				((LLFloater::isVisible(im_box) && !nearby_chat->isTornOff() && !im_box->isMinimized())
-						|| (LLFloater::isVisible(nearby_chat) && nearby_chat->isTornOff() && !nearby_chat->isMinimized())))))
-		{
-			if(nearby_chat->isMessagePaneExpanded())
-			{
-				return;
-			}
-		}
+		// This is insane.
+		//bool chat_overlaps = false;
+		//if(nearby_chat->getChatHistory())
+		//{
+		//	LLRect chat_rect = nearby_chat->getChatHistory()->calcScreenRect();
+		//	for (std::list<LLView*>::const_iterator child_iter = gFloaterView->getChildList()->begin();
+		//		 child_iter != gFloaterView->getChildList()->end(); ++child_iter)
+		//	{
+		//		LLView *view = *child_iter;
+		//		const LLRect& rect = view->getRect();
+		//		if(view->isInVisibleChain() && (rect.overlaps(chat_rect)))
+		//		{
+		//			if(!nearby_chat->getChatHistory()->hasAncestor(view))
+		//			{
+		//				chat_overlaps = true;
+		//			}
+		//			break;
+		//		}
+		//	}
+		//}
+		////Don't show nearby toast, if conversation is visible and selected
+		//if ((nearby_chat->hasFocus()) ||
+		//	(LLFloater::isVisible(nearby_chat) && nearby_chat->isTornOff() && !nearby_chat->isMinimized()) ||
+		//    ((im_box->getSelectedSession().isNull() && !chat_overlaps &&
+		//		((LLFloater::isVisible(im_box) && !nearby_chat->isTornOff() && !im_box->isMinimized())
+		//				|| (LLFloater::isVisible(nearby_chat) && nearby_chat->isTornOff() && !nearby_chat->isMinimized())))))
+		//{
+		//	if(nearby_chat->isMessagePaneExpanded())
+		//	{
+		//		return;
+		//	}
+		//}
 
         //Will show toast when chat preference is set        
         if((gSavedSettings.getString("NotificationNearbyChatOptions") == "toast") || !nearby_chat->isMessagePaneExpanded())
diff --git a/indra/newview/llfloaterimsessiontab.h b/indra/newview/llfloaterimsessiontab.h
index 34f4ea6c1c16c7d495fe04e99c0fed57b2fb6d94..a28f1d1087cce6f66b04871f74d08c682c8d31ac 100644
--- a/indra/newview/llfloaterimsessiontab.h
+++ b/indra/newview/llfloaterimsessiontab.h
@@ -96,7 +96,7 @@ class LLFloaterIMSessionTab
 	LLConversationItem* getCurSelectedViewModelItem();
 	void forceReshape();
 	virtual BOOL handleKeyHere( KEY key, MASK mask );
-	bool isMessagePaneExpanded(){return mMessagePaneExpanded;}
+	bool isMessagePaneExpanded() const {return mMessagePaneExpanded;}
 	void setMessagePaneExpanded(bool expanded){mMessagePaneExpanded = expanded;}
 	void restoreFloater();
 	void saveCollapsedState();