Now update `import_gmail_threads` to accept `account_id` so it can use the right Gmail account.


Edit

        case 'import_gmail_threads':
            if ($_SERVER['REQUEST_METHOD'] !== 'POST') jsonError('POST required', 405);
            $jsonData = json_decode(file_get_contents('php://input'), true) ?? [];
            $threadIds = $jsonData['thread_ids'] ?? [];
            if (empty($threadIds)) jsonError('thread_ids required');

            try {
                $gmail = new \EmailIntelligence\GmailClient();
                $userEmail = strtolower(GMAIL_USER_EMAIL);

        case 'import_gmail_threads':
            if ($_SERVER['REQUEST_METHOD'] !== 'POST') jsonError('POST required', 405);
            $jsonData = json_decode(file_get_contents('php://input'), true) ?? [];
            $threadIds = $jsonData['thread_ids'] ?? [];
            $importAccountId = $jsonData['account_id'] ?? null;
            if (empty($threadIds)) jsonError('thread_ids required');

            try {
                // Use specific account if provided, otherwise primary
                $gmail = $importAccountId
                    ? new \EmailIntelligence\GmailClient((int)$importAccountId)
                    : new \EmailIntelligence\GmailClient();
                $userEmail = strtolower($gmail->getUserEmail() ?? GMAIL_USER_EMAIL);