This diff addresses ENG-4452: Messages creating threads are being swallowed.
The root cause is that the code in updateMessageStoreWithLatestThreadInfos required that messages in the MessageStore had a corresponding ThreadInfo in the ThreadStore. More details on this requirement:
- This requirement was enforced every time that updateMessageStoreWithLatestThreadInfos was called. This function is triggered on a variety of Redux actions, including state syncs, new messages or updates being pushed to the client, and the user scrolling in the MessageList.
- The code that enforces this requirement in updateMessageStoreWithLatestThreadInfos functions by first filtering the ThreadStore based on isThreadWatched, and then filtering the MessageStoreThreads based on the filtered ThreadStore. Pending threads would normally pass isThreadWatched, but since those pending threads don't appear in ThreadStore, they were excluded by this algorithm.
- This requirement appears to have been in our code for over 2 years. I didn't get back far enough, but it's likely that it predates the introduction of "pending threads".
The issue resolved by this diff occurred because the "pending threads" code persist pending messages to the MessageStore, but does NOT persist pending threads to the ThreadStore. The aforementioned requirement broke this behavior by filtering out messages that didn't have a corresponding thread in the ThreadStore.