Skip to content

Attribute thread summary avatars to the copilot who commented - #100012

Merged
mollfpr merged 3 commits into
Expensify:mainfrom
mukhrr:fix/98573
Sep 21, 2026
Merged

mollfpr merged 3 commits into
Expensify:mainfrom
mukhrr:fix/98573

Conversation

@mukhrr

@mukhrr mukhrr commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

The thread summary avatars come only from childOldestFourAccountIDs on the parent report action. That field was written from the session account, which while connected as a copilot is the account being acted for, not the copilot. The same send stamps the copilot onto the reply via delegateAccountID, so the summary showed a different person than the comment above it.

This writes the same effective author into the field, and uses it for the duplicate check so a copilot replying twice still counts as one commenter. Ordinary comments are unaffected, and the new parameter defaults to the previous behaviour so other callers are untouched.

The API now stores the copilot in this field for new replies, so once the server responds the summary is already correct. This change makes the pending and offline states match it, so the avatar no longer flips to the account acted for while a reply is in flight.

Fixed Issues

$ #98573
PROPOSAL: #98573 (comment)

Tests

Requires two accounts with a Full copilot relationship and different avatars.

  1. Sign in as the copilot account, then go to Account > Profile, click the account row at the top of the left nav, click Switch, and select the account you are a copilot for.
  2. Send a message in any chat. Verify it shows the copilot's avatar and an "on behalf of ..." sub-line.
  3. Right click the message and select Reply in thread.
  4. Go offline.
  5. Send one reply in the thread, then return to the parent chat, staying offline.
  6. Compare the avatar on the parent message with the avatar on the "1 Reply" row under it. Verify both show the copilot. Before this change the summary showed the account acted for.
  • Verify that no errors appear in the JS console

Offline tests

  1. Same as tests, steps 4 to 6 are performed offline.
  2. Go back online and verify the summary avatar stays the copilot's after the reply syncs. Before this change it showed the account acted for until the server response arrived.

QA Steps

Same as tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

The thread summary under a message builds its avatars only from
childOldestFourAccountIDs on the parent action. That field was written
from the session account, which while connected as a copilot is the
account being acted for, not the copilot. The same send stamps the
copilot onto the reply via delegateAccountID, so one optimistic write
produced two different identities and the summary showed a different
person than the comment above it.

Pass the effective author the optimistic action was already stamped with
into the ancestor update, and use it for the duplicate check as well so a
copilot replying twice is still counted as one commenter.

The server writes the same field delegate-blind, so this keeps only the
pending and offline states consistent until that is changed too.
@mukhrr
mukhrr requested review from a team as code owners September 1, 2026 09:42
@melvin-bot
melvin-bot Bot requested review from flaviadefaria and thelullabyy and removed request for a team September 1, 2026 09:42
@melvin-bot

melvin-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

@thelullabyy Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot removed the request for review from a team September 1, 2026 09:42
@mukhrr

mukhrr commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor Author

@mollfpr can you pls assign an internal engineer for BE changes?

childOldestFourAccountIDs records the account acted for, not the copilot

The thread summary avatar is built only from childOldestFourAccountIDs on the parent report action. For a thread whose reply was posted by a copilot, the server returns that field set to the account being acted for, while the reply itself carries the copilot in delegateAccountID. So the summary renders a different person than the comment directly above it.

Evidence, two OpenReport calls against staging. Accounts: 22340909 is the copilot, 22532870 is the account acted for.

1. The thread's reply — attributed to the copilot

POST /api/OpenReport
  reportID=6971765021051531

reportActions_6971765021051531:
{
  "reportActionID": "8998634924973878647",
  "actionName": "ADDCOMMENT",
  "actorAccountID": 22532870,
  "delegateAccountID": 22340909,     <-- copilot
  "message": [{"text": "green run reply"}]
}

2. Its parent action — summary records the account acted for

POST /api/OpenReport
  reportID=7283996934100375
  reportActionID=7571172644691364988

reportActions_7283996934100375["7571172644691364988"]:
{
  "reportActionID": "7571172644691364988",
  "actorAccountID": 22532870,
  "delegateAccountID": 22340909,
  "childReportID": "6971765021051531",
  "childOldestFourAccountIDs": "22532870",   <-- account acted for, not the copilot
  "childCommenterCount": 1,
  "childVisibleActionCount": 1
}

The only reply in that thread is 8998634924973878647, whose effective author is 22340909, yet the parent records 22532870.

when maintaining childOldestFourAccountIDs for a thread reply, store the child action's delegateAccountID when present and fall back to actorAccountID otherwise.

@mollfpr

mollfpr commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

The BE PR is open!

@thelullabyy

Copy link
Copy Markdown
Contributor

@mukhrr Could you please add prefix [Hold] to this PR until BE PR is merged

@mukhrr mukhrr changed the title Attribute thread summary avatars to the copilot who commented [HOLD]Attribute thread summary avatars to the copilot who commented Sep 8, 2026
@mukhrr

mukhrr commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

The BE PR is open!

@mollfpr any news on this BE PR?

@mollfpr

mollfpr commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

@mukhrr the BE PR is in production now 🙌

@mukhrr mukhrr changed the title [HOLD]Attribute thread summary avatars to the copilot who commented Attribute thread summary avatars to the copilot who commented Sep 11, 2026
@mukhrr

mukhrr commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

@mukhrr the BE PR is in production now 🙌

thanks! @thelullabyy I think we are good to move now

@mukhrr

mukhrr commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

@thelullabyy kindly bump

@thelullabyy

thelullabyy commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

MacOS: Chrome / Safari
Screen.Recording.2026-09-19.at.02.07.27.mov

@thelullabyy

Copy link
Copy Markdown
Contributor

@mukhrr Could you please merge main?

return update.value?.[PARENT_REPORT_ACTION_ID];
}

function buildReply(delegateAccountIDParam: number | undefined) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the unit tests don't cover the actual fix, we should add test that drives addActions / addComment end-to-end

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok i will add necessary ones

Comment thread src/libs/ReportUtils.ts
* @param type The type of action in the child report
*/
function getOptimisticDataForAncestors(ancestors: Ancestor[], lastVisibleActionCreated: string, type: string): Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS>> {
function getOptimisticDataForAncestors(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we update two other places write the same field optimistically?

  • src/libs/actions/IOU/Hold.ts:145 - delegateAccountID is already used to stamp buildOptimisticHoldReportActionComment, but isn't forwarded here.
  • src/libs/actions/Task.ts:375 - delegateAccountID is a param of createTaskAndNavigate and is already used for buildOptimisticTaskCommentReportAction.

…d summary

Hold and task comments already stamp delegateAccountID on the comment
action but did not pass it to the ancestor update, so a copilot's hold
or task comment still recorded the account acted for in the parent's
childOldestFourAccountIDs. Read the effective author back off the built
action, as addActions does, so the summary and the comment agree.

Also cover addComment end to end: the existing tests exercised the
ReportUtils helper directly and passed with the addActions call site
reverted, so they did not prove the call site forwarded the delegate.

@thelullabyy thelullabyy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@melvin-bot
melvin-bot Bot requested a review from mollfpr September 18, 2026 18:09
@mollfpr
mollfpr merged commit fab6b44 into Expensify:main Sep 21, 2026
35 of 37 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 mollfpr has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mollfpr in version: 9.4.91-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 No help site changes are required for this PR, so I did not create a docs PR.

Why: this is an internal correctness fix to optimistic (pending/offline) data, not a product change. It makes childOldestFourAccountIDs use the effective comment author (the copilot, via delegateAccountID) so the thread summary avatar matches the avatar already rendered on the comment — which is what the API has been storing all along. No user-facing copy, button label, setting, tab, or flow changed, and no new capability was added.

What I checked in docs/articles

Per HELP_AUTHORING_GUIDELINES.md, help articles document what a customer needs to do, not internal state-handling details. Adding an article line about avatar attribution in a pending thread reply would document a bug that no longer exists.

One thing worth a separate look (not caused by this PR, so I left it alone): the copilot switch steps in the article read Account > Copilot > Switch, while this PR's test steps describe going through Account > Profile and using the account row at the top of the left nav. I did not verify which one matches the current UI, so I'm flagging it rather than asserting the article is stale. If you want, reply with @MelvinBot verify the Copilot switch steps in Act-as-a-Copilot.md against the current UI and fix them and I'll test it and open a docs PR if it's out of date.

@mukhrr, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/lakchote in version: 9.4.91-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants