Files
twenty/packages
Sonarly Claude Code 45e3da0527 Microsoft email folder filters ignored during sync
https://sonarly.com/issue/26908?type=bug

When users select "Some folders" and pick specific subfolders for Microsoft/Outlook email sync, ALL emails are imported because the backend only discovers top-level mail folders from the Microsoft Graph API and never finds the user-selected child folders.

Fix: Added recursive child folder discovery to MicrosoftGetAllFoldersService. The existing code only called /me/mailFolders which returns top-level Microsoft mail folders. When a user selected "Some folders" and picked a subfolder (e.g., "Inbox/Twenty"), that subfolder was never discovered by the backend, so it could never have isSynced=true, and the isSynced filter in the message list service would find zero matching folders.

The fix adds a private fetchFoldersRecursively method that checks each folder's childFolderCount (already present in the Microsoft Graph API response and already typed in MicrosoftGraphFolder). For folders with children, it calls /me/mailFolders/{id}/childFolders to fetch nested folders, and recurses for any deeper nesting. The error handling follows the same .catch() pattern used for the top-level folder fetch — errors are logged and return empty results rather than breaking the entire sync.

The downstream isSynced filtering in MicrosoftGetMessageListService (line 41-44) already correctly filters folders when SELECTED_FOLDERS policy is active, and the early-exit guard (line 47) already returns empty when no folders match. The only missing piece was that child folders were never discovered in the first place.
2026-04-16 07:22:32 +00:00
..
2026-04-13 15:13:11 +02:00