This is the code that chooses which session to keep and which to reset.
When there is a race condition and the device has a higher deviceID - ignore the request (the other device will get our session request and then decide to accept the session as it has a lower deviceID). Already queued messages can be ignored, while decrypting we will get OLM_SENDER_CHAIN_NOT_ACKNOWLEDGED which is different than BAD_MESSAGE_MAC so those messages will not cause a resetting session again.
When there is a race condition and the device has a lower deviceID - overwrite session and resend all messages, there is a separate task to work on this (see comment).
Depends on D11595