Currently, the app will crash if you attempt to create a sidebar from a `CHANGE_ROLE` robotext message. This is because when attempting to create the role, the `threadInfo` passed into [[
https://github.com/CommE2E/comm/blob/2954159c828eb81b8042af4572632924a4a6a563/lib/shared/message-utils.js#L74 | robotextForMessageInfo ]] from [[
https://github.com/CommE2E/comm/blob/2954159c828eb81b8042af4572632924a4a6a563/lib/selectors/chat-selectors.js#L532-L535 | chat-selectors.js ]] is undefined. The reason for this is in a pending sidebar, if you
check the `threadID`, it is something like `pending/sidebar/256|90231`. Here, the `256|90231` corresponds to the source message that the sidebar is being created from, i.e. the message that the user clicks
'create thread' on.
To resolve this, we want to extend the `RobotextParams` to include a potentially null `parentThreadInfo`, and modify the call site in `chat-selectors.js`. To get the `parentThreadInfo`, we'd do the following:
1. Parse out the source message ID from the pending sidebar thread ID
2. Access `messageStore.messages` for the source message
3. Read the `threadID` from the source message info
4. Access the `ThreadInfo` from the `threadInfos` object using the newly found `threadID`
With this, we will now be able to access either the regular `threadInfo` or the `parentThreadInfo` in the `CHANGE_ROLE` message spec, no longer crashing the app. We can now re-allow sidebars to be created
from `CHANGE_ROLE` messages as well.
One thing to note is the other callsite for `robotextForMessageInfo` is in [[ https://github.com/CommE2E/comm/blob/125b29a6d73e200bcfb18fea1b47154887b105a8/lib/shared/message-utils.js#L426 | getMessageTitle
]]. Though when looking into what `threadInfo` is passed into it, it already receives the `parentThreadInfo` from [[
https://github.com/CommE2E/comm/blob/125b29a6d73e200bcfb18fea1b47154887b105a8/lib/shared/thread-utils.js#L609 | createPendingSidebar ]]. So I don't think we should have to update anything there.
This is @ashoat's suggestion (#5) addressing [[ https://linear.app/comm/issue/ENG-4981/attempt-to-create-thread-from-change-role-robotext-message-fails#comment-fbd19530 | ENG-4981 ]].