Mutt has the ability to dynamically restructure threads that are broken either by misconfigured software or bad behaviour from some correspondents. This allows to clean your mailboxes formats) from these annoyances which make it hard to follow a discussion.
If you want to use these functions with IMAP, you need to compile Mutt with the --enable-imap-edit-threads configure flag.