Fix vacation delegate split creating phantom self-DM reports#84541
Draft
Fix vacation delegate split creating phantom self-DM reports#84541
Conversation
When a vacation delegate splits an expense, getMoneyRequestParticipantsFromReport()
fails to resolve the owner's policy expense chat (not in delegate's Onyx), returning
an empty participants array. This cascades: [] -> {} -> NaN payerAccountID -> phantom
optimistic chat reports appearing as duplicate self-DMs in the LHN.
Add a fallback in getMoneyRequestParticipantsFromReport() that constructs the
participant from the expense report's own chatReportID and policyID when the chat
report is missing from Onyx but the report is a known expense report with policy data.
Co-authored-by: Situ Chandra Shil <situchan@users.noreply.github.com>
8 tasks
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation of Change
When a vacation delegate splits an expense,
getMoneyRequestParticipantsFromReport()tries to look up the owner's policy expense chat viagetReportOrDraftReport(report.chatReportID). However, vacation delegates don't have the expense owner's policy expense chat in their Onyx store (unlike copilot delegation, vacation delegation doesn't switch sessions). This causeschatReportto beundefined, and the function falls through to theelsebranch which returns an empty participants array[].This empty array cascades through the split flow:
participants.at(0) ?? ({} as Participant)coerces[]to{}Number(undefined)producesNaNforpayerAccountIDgetChatByParticipants([NaN, payeeAccountID])finds no matchbuildOptimisticChatReportcreates phantom chat reports withNaNparticipantsThe fix adds a fallback branch in
getMoneyRequestParticipantsFromReport(): when the chat report is missing from Onyx but the report is a known expense report withchatReportIDandpolicyID, we construct the participant directly from the expense report's own metadata. This mirrors the same participant shape that the function would produce if the policy expense chat were present.Fixed Issues
$ #76671
PROPOSAL: #76671 (comment)
Tests
Offline tests
N/A - This fix addresses participant resolution logic that runs during the optimistic data creation phase. Offline behavior is unchanged since the split flow already handles optimistic updates.
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
N/A - Logic-only change, no UI modifications
Android: mWeb Chrome
N/A - Logic-only change, no UI modifications
iOS: Native
N/A - Logic-only change, no UI modifications
iOS: mWeb Safari
N/A - Logic-only change, no UI modifications
MacOS: Chrome / Safari
N/A - Logic-only change, no UI modifications