Repository navigation
Pass linkedTransaction to getReportPreviewMessage from the LHN - #104006
Conversation
The general path now looks up the IOU action's transaction in the report's own transactions via getLinkedIOUTransaction. Split and track actions keep their transaction outside the report, so the LHN row reads it from Onyx and passes it through getOptionData -> getReportAlternateText -> getLastMessageTextForReport. Callers that don't pass it yet (Search) still fall back to the deprecated lookup. Part of Expensify#66418
|
@MelvinBot Review |
ReviewNo blocking issues. The change looks correct, and CI is green except the two checklist checks. I checked every caller of Suggestions:
|
|
@DylanDylann 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] |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…nsaction-in-getReportPreviewMessage
| convertToDisplayString: CurrencyListActionsContextType['convertToDisplayString'], | ||
| params: GetReportPreviewMessageBaseParams, | ||
| params: GetReportPreviewMessageBaseParams & { | ||
| linkedTransaction?: OnyxEntry<Transaction>; |
There was a problem hiding this comment.
Let's define linkedTransaction inside GetReportPreviewMessageBaseParams
There was a problem hiding this comment.
Done in 7c9e85e. I also left it out of getReportPreviewReportActionMessage, which shares the type but doesn't use it.
| // This covers group chats where the last action is a split expense action | ||
| const linkedTransaction = getLinkedTransaction(iouReportAction); | ||
| // The split transaction belongs to SPLIT_REPORT_ID, not to `report`, so it isn't in `allReportTransactions` and the caller has to pass it. | ||
| const linkedTransaction = getLinkedTransaction(iouReportAction, linkedTransactionParam ? [linkedTransactionParam] : undefined); |
There was a problem hiding this comment.
Why do we need to use getLinkedTransaction function anymore?
There was a problem hiding this comment.
We still need it in this PR for two reasons:
- Search (
OptionsListUtils→getReportAlternateText) doesn't passlinkedTransactionyet. When the param is undefined,getLinkedTransactionfalls back to the Onyx lookup, so Search keeps showing split/track previews. Refactor/66418 pass linked transaction from search #104079 wires Search up. - It checks that the passed transaction's ID matches the action's
IOUTransactionID. That guards against the caller's last action differing from the one we're rendering.
There was a problem hiding this comment.
@linhvovan29546 I don’t think we should call getLinkedTransaction when linkedTransactionParam is already passed. I’m fine with keeping getLinkedTransaction as a fallback until the refactor is done.
About the IOUTransactionID check: could we do it when defining linkedTransactionParam instead?
There was a problem hiding this comment.
Done in a49a9cb. getReportPreviewMessage now uses linkedTransactionParam ?? getLinkedTransaction(iouReportAction), so the Onyx lookup only runs as the fallback for Search until #104079. I moved the IOUTransactionID check to where linkedTransaction is passed in getLastMessageTextForReport, not OptionRowLHNData. That function can swap the rendered action for the parent's last action in one-transaction reports, so the check has to compare against the action that's actually rendered. I added a test for the mismatch case.
There was a problem hiding this comment.
@linhvovan29546 Oh, my bad. It’s actually better to use getLinkedTransaction as before. That was my mistake in the earlier review
There was a problem hiding this comment.
No worries, reverted in 7736c30. Both branches use getLinkedTransaction(iouReportAction, linkedTransactionParam ? [linkedTransactionParam] : undefined) again, and the extra guard in getLastMessageTextForReport is gone.
| let linkedTransaction; | ||
| if (!isEmptyObject(iouReportAction) && shouldConsiderScanningReceiptOrPendingRoute && iouReportAction && isMoneyRequestAction(iouReportAction)) { | ||
| linkedTransaction = getLinkedTransaction(iouReportAction); | ||
| linkedTransaction = getLinkedTransaction(iouReportAction, allReportTransactions); |
There was a problem hiding this comment.
Can we use linkedTransactionParam here?
There was a problem hiding this comment.
The LHN only passes linkedTransaction for split and track actions. We narrowed it in the earlier review to avoid a transaction subscription on every IOU/expense row. On this general path the IOU action's transaction belongs to report, so it's already in allReportTransactions. Looking it up there avoids both the deprecated global and an extra subscription. linkedTransactionParam would always be undefined here.
There was a problem hiding this comment.
@linhvovan29546 What’s your plan for removing allReportTransactions going forward? What do you think if we should pass allReportTransactions instead of linkedTransactionParam?
There was a problem hiding this comment.
Then linkedTransaction can be computed inside the function from allReportTransactions
There was a problem hiding this comment.
allReportTransactions alone can't replace it. Split transactions live under SPLIT_REPORT_ID and tracked ones are unreported, so neither is in the report's transactions. Removing getReportTransactions(report.reportID) here is a later step of #66418, where callers pass the report's transactions. That needs useReportTransactions per LHN row, so I'd keep it out of this PR. If you'd like, that PR can merge both into one transactions param and do the lookup inside.
…-getLinkedTransaction-in-getReportPreviewMessage # Conflicts: # src/libs/ReportAlternateTextUtils.ts
…-getLinkedTransaction-in-getReportPreviewMessage # Conflicts: # src/components/LHNOptionsList/OptionRowLHN/OptionRowLHNData.tsx # src/libs/ReportAlternateTextUtils.ts # src/libs/ReportUtils.ts # src/libs/SidebarUtils.ts
… to getReportPreviewMessage getReportPreviewMessage now uses the passed transaction directly and only falls back to the Onyx lookup when none is passed.
|
Looks like our issue is the fallback when computing lastReportAction, which is why you were worried about computing the transaction from lastAction. I just checked the previous commits again, and it looks like we can safely remove this fallback. That way, we can simply compute linkedTransaction in the UI. Would love to hear your thoughts before moving forward App/src/libs/ReportAlternateTextUtils.ts Line 543 in ba97c03 |
getReportPreviewMessage goes back to getLinkedTransaction, which already matches the passed transaction against the action's IOUTransactionID. Both callers of getLastMessageTextForReport (the LHN and Search) pass the lastAction they computed with getLastVisibleActionIncludingTransactionThread, so the getLastVisibleAction fallback never found anything. Tests that relied on it now pass lastAction like the real callers do.
|
@DylanDylann Agreed, and done in 7736c30. Both callers already pass My earlier worry was actually the one-transaction block just below, which swaps an IOU CREATE/TRACK for the parent's last action. I kept that one, because removing it changes the LHN text for one-transaction expense/IOU reports. It doesn't affect this PR, though. It only runs when there's a |
Reviewer Checklist
Screenshots/VideosScreen.Recording.2026-10-26.at.12.11.30.mov |
…-getLinkedTransaction-in-getReportPreviewMessage # Conflicts: # src/components/LHNOptionsList/OptionRowLHN/OptionRowLHNData.tsx # src/libs/ReportUtils.ts
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
getReportPreviewMessage only falls back to getLinkedTransaction when no transaction is passed, which is still the case for Search until Expensify#104079. Also formats the Omit list re-added in the main merge.
…-getLinkedTransaction-in-getReportPreviewMessage # Conflicts: # src/components/LHNOptionsList/OptionRowLHN/OptionRowLHNData.tsx # src/libs/ReportAlternateTextUtils.ts # src/libs/ReportUtils.ts
|
@MelvinBot Review |
ReviewNo blocking issues. The code is correct, and every CI check passes except Things I checked:
Suggestions:
|
…-getLinkedTransaction-in-getReportPreviewMessage
|
@Julesssss could you take a look when you have a moment? |
|
🚧 Julesssss has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/Julesssss in version: 9.5.37-0 🚀
|
|
No help site update needed — this PR refactors how existing expense previews retrieve transaction data without adding a workflow, changing UI labels, removing a beta, or making existing article guidance incorrect. |
|
🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.5.37-1 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
Part of the
deprecatedAllTransactionscleanup.getReportPreviewMessagenow takes the IOU action's transaction from its caller or from the report's own transactions, instead of the deprecated global.reportIDisSPLIT_REPORT_IDor unreported), so it can't come fromallReportTransactions. These branches now use thelinkedTransactionparam, which the LHN already passes on main aslastActionTransaction(OptionRowLHNDatasubscribes to the last money request action's transaction and passes it throughgetOptionData→getReportAlternateText→getLastMessageTextForReport).linkedTransactionis still used when it matches the action'sIOUTransactionID. Otherwise the transaction is looked up in the report's own transactions withgetLinkedTransaction(iouReportAction, allReportTransactions), since it belongs toreport.getLastMessageTextForReport: removed thelastAction ?? getLastVisibleAction(...)fallback and the!lastActiontransaction thread lookup, and madelastActionrequired. Both callers (the LHN, and Search viaresolveLastActionContext) already pass thelastActionthey compute withgetLastVisibleActionIncludingTransactionThread, so the fallback never found anything.linkedTransactionyet, so split/track still fall back to the deprecated lookup when it's missing. Refactor/66418 pass linked transaction from search #104079 passes it from Search, and the fallback can be removed after that.Fixed Issues
$ #66418
PROPOSAL: N/A
Tests
Split expense in a group chat
Track expense in the self DM
Expense in a DM (regression check)
Search (regression check)
Offline tests
Same as tests.
QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)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.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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
Screen.Recording.2026-10-15.at.18.17.59.mov
MacOS: Chrome / Safari