[lib/native] fix @-mentioning in a create new pending GENSIS chat crashes app
Summary:
After putting up a solution for fixing @ mentioning in pending GENESIS sidebars in D10956, as a sanity check I wanted to check other places where we have pending threads and see if these also have issues when using the @ mentioning feature. I'm glad I did, because I also found an issue when creating a new standard pending GENESIS chat and using the @ mentioning would cause the app to crash.
The cause of the crash was the same as in D10956 where we were attempting to get the chat mention search index from the communityThreadIDForGenesisThreads, but since this new pending thread wasn't resolved yet, it is not part of communityThreadIDForGenesisThreads so we were returning an chatSearchIndex as undefined even though in useMentionTypeaheadChatSuggestions we guarantee that there is a value there.
A pending standard GENESIS chat shouldn't have any resolved sidebars or subchannels, so we really shouldn't be returning anything from useMentionTypeaheadChatSuggestions in the first place. A solution that made sense to me here was to type the chatSearchIndex parameter as optional and have a check where if the chatSearchIndex is not set we just return the blank array that we initialized in the beginning as our list of MentionTypeaheadChatSuggestionItems.
Depends on D10956
Test Plan:
Please see demo video below (also confirmed that native counterpart works too)
Reviewers: atul, inka, ashoat
Reviewed By: atul, ashoat
Subscribers: ashoat, tomek
Differential Revision: https://phab.comm.dev/D10957