TNL-549: Fix thread editing.

**Ticket:** [TNL-549](https://openedx.atlassian.net/browse/TNL-549)

@jimabramson , @tymofij, @cahrens  please review.
i don't know if the algorithm can be optimized, but the expensive part is `get_discussion_category_map` and I don't see any alternative to using that which wouldn't require massive refactoring.