Correctly update thread tags in IMAP sync.

Summary:
With this commit, we update a thread's tags by aggregating over all ImapUid
folders and labels to figure out what the tags should be. Previously, we
wouldn't remove the inbox tag if the \Inbox *label* was removed from an All
Mail UID -- only if we synced a deleted Inbox UID. This wouldn't work if the
Inbox folder syncs lagged such that we never actually saw an Inbox UID for the
message.

Fixes T632.

Test Plan:
Run syncs and check that the inbox tag is removed from archived
threads. Automated tests to come, but I want to put this on staging sooner
rather than later.

Reviewers: spang, khamidou

Reviewed By: khamidou

Maniphest Tasks: T632

Differential Revision: https://review.inboxapp.com/D810