Each message in the DB is identified by the ID. Failed messages don't have an ID - instead they have a localID. When a failed message is saved to the DB, its ID is set to be equal to its localID. When fetching from the DB, we have to make sure the message looks the same as before saving it - this means that we have to remove the ID from messages that lso have localID. It was done in D2601.
This mechanism causes issues in our mergeNewMessages method, where we assume that the ID is set. This function was designed to handle incoming messages that from their nature are never failed. In order to fix this function, we have to make sure that an invariant isn't triggered and that we keep the localID of a message.
This issue only affects thick threads with more than 20 messages. Fetching the initial messages works correctly - and we're fetching all the local thin thread messages and up to 20 thick thread messages.
https://linear.app/comm/issue/ENG-10734/fetching-failed-thick-thread-messages-fails