getRecipients builds the reply recipients from the last email in a conversation. For an incoming email, it is expected to move extra To recipients into the reply cc (minus the inbox address). It does not. The incoming branch hardcodes the To list to empty:
if (isIncoming) {
...
emailAttributes = {
cc: email?.cc || [],
bcc: email?.bcc || [],
from: email?.from || [],
to: [], // <-- drops the email's actual To recipients
};
}
So this later step is always a no-op for incoming emails:
// Only include 'to' recipients in cc for incoming emails, not for outgoing
if (Array.isArray(emailAttributes.to) && isIncoming) {
cc.push(...emailAttributes.to);
}
Effect in Chatwoot: a customer sends an email to the inbox with a colleague in the To line (not CC). The agent replies from the dashboard. The reply box computes an empty CC and the colleague silently falls off the thread.
Repro:
getRecipients(
incomingEmail({ from: ['customer@example.com'], to: ['inbox@co.com', 'colleague@example.com'] }),
'customer@example.com',
'inbox@co.com',
''
);
// actual: cc = []
// expected: cc = ['colleague@example.com']
Regression: before #43 the function read the raw email object, so emailAttributes.to held the real To list and the cc.push worked. #43 restructured the branches and zeroed to for incoming; #50 kept the guard but the array is always empty. There is no test covering an incoming email with extra To recipients — the createIncomingEmail fixture has no to field at all.
Fix incoming: pass email?.to || [] so the existing cc-building step and filters work again.
getRecipientsbuilds the reply recipients from the last email in a conversation. For an incoming email, it is expected to move extraTorecipients into the replycc(minus the inbox address). It does not. The incoming branch hardcodes the To list to empty:So this later step is always a no-op for incoming emails:
Effect in Chatwoot: a customer sends an email to the inbox with a colleague in the To line (not CC). The agent replies from the dashboard. The reply box computes an empty CC and the colleague silently falls off the thread.
Repro:
Regression: before #43 the function read the raw email object, so
emailAttributes.toheld the real To list and thecc.pushworked. #43 restructured the branches and zeroedtofor incoming; #50 kept the guard but the array is always empty. There is no test covering an incoming email with extra To recipients — thecreateIncomingEmailfixture has notofield at all.Fix incoming: pass
email?.to || []so the existing cc-building step and filters work again.