On desktop we show categories and topics separately, but on mobile we show categories with topics, combined. Keeping that in mind, it is this line that causes the bug:
c.displayable_topics.blank? is always true on desktop because we load topics separately so
displayable_topics is always blank. On mobile, it is true only if there are really no topics in that category.
We have two solutions here:
show uncategorized if there is at least a topic, no matter the value of ‘allow uncategorized topics’ setting
hide uncategorized even if there is a topic, if ‘allow uncategorized topics’ is false
The second solution is easier to implement because it means we simply remove the second part of the condition.