Unread direct message channels not shown in sidebar

Sometimes there is an unread direct/group channel that should be shown in the sidebar as unread (i.e. in bold), but it is not shown there and the messages get missed.

Steps to reproduce
Seen with mattermost 5 (various versions) and confirmed again today on 6.3.7. No known steps to reproduce reliably.
I do not know whether there are any consistent user settings that are always present when this occurs because I have had only had a lot of indirect reports of it. When observing the issue myself, it has been when using channel groups, where the messages should be in the collapsed “Direct Messages” group but no channel is shown there.

Expected behavior
When someone messages me in a direct/group channel, the channel should appear in the sidebar and be marked as unread.

Observed behavior
Occasionally this fails to happen for a specific direct/group channel. Even when there are more messages later in the same channel, it still doesn’t appear as unread in the sidebar. That situation can persist for hours. In this case the unread messages indicator (e.g. the dot on the app icon) does indicate an unread message, even if the UI shows no channels at all as being unread in the sidebar. This may lead the user to realise that something is not being shown because the UI shows all channels as read, yet the unread indicator on the icon says that something is unread; the user then refreshes the client, and finds an entire conversation waiting to be read.

Refreshing the client resolves the issue and the channel is then shown as unread.

I am guessing this will be impossible to follow up without steps to reproduce it, but maybe a workaround is to have the client periodically do a safety check / re-check of unread channels? Even if that was done once per minute, it would be a lot better than the current situation.

I would say I see this behaviour about once a month, and I have had dozens of other users in the organisation complain about it.