Skip to content

Part 5- thread reportOwnerLogin through canDeleteReportAction and the merge predicates - #102260

Merged
danieldoglas merged 18 commits into
Expensify:mainfrom
Krishna2323:krishna2323/issue/66413/part-4a
Oct 21, 2026
Merged

danieldoglas merged 18 commits into
Expensify:mainfrom
Krishna2323:krishna2323/issue/66413/part-4a

Conversation

@Krishna2323

@Krishna2323 Krishna2323 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Fixed Issues

$ #66413
PROPOSAL:

Tests

Setup: Workspace on Advanced approval. A submits to B, B forwards to C. A is a member, not an admin. As A, submit one expense report with a single expense and leave it submitted. Steps 1-5 all use that same report.

Tests

  1. Report menu: As A, open the report. Under More, Delete and Merge are available.
  2. Report preview: In chat, right-click/long-press that report's preview. Delete appears.
  3. Search bulk delete: In Search, select that report. Delete appears.
  4. Search merge, same owner: As A, submit a second expense report into the same workspace. Select both in Search. Merge appears.
  5. Transaction merge: Open a transaction on the report, More, Merge. The eligible transactions list loads and is not empty.
  6. After forwarding: As B, approve so the report forwards to C. As A, reopen it. Delete and Merge are gone from both the More menu and the report preview context menu. This is the main regression check, and it needs the full A to B to C chain. Fully approving with a single approver hides Delete for a different reason and does not cover this code path.
  7. Search merge, mixed owners: Select one of A's reports and one of another member's. Merge does not appear. Do not skip this cross-account guard.
  8. Offline merge: Go offline, open a transaction, and start Merge. The eligible transactions match what step 5 showed.
  • Verify that no errors appear in the JS console

Offline tests

  • Same as tests

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
    • MacOS: Desktop
  • 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 verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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
Monosnap.screencast.2026-10-02.16-56-29.mp4

…redicates

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@codecov

codecov Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/components/Search/selectionBuilders.ts 99.18% <ø> (ø)
src/hooks/useSearchBulkActions.ts 80.74% <100.00%> (ø)
src/hooks/useSelectedTransactionsActions.ts 79.78% <100.00%> (+0.22%) ⬆️
src/libs/OptionsListUtils/index.ts 91.87% <ø> (ø)
src/libs/ReportSecondaryActionUtils.ts 96.40% <100.00%> (+<0.01%) ⬆️
src/libs/ReportUtils.ts 88.76% <100.00%> (+<0.01%) ⬆️
src/libs/SearchUIUtils.ts 73.64% <100.00%> (+<0.01%) ⬆️
src/libs/UnreadIndicatorUpdater/index.ts 98.27% <ø> (+5.17%) ⬆️
src/libs/actions/Link.ts 68.35% <ø> (ø)
src/libs/actions/MergeTransaction.ts 90.38% <100.00%> (ø)
... and 5 more
... and 10 files with indirect coverage changes

…Approval

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@Krishna2323 Krishna2323 changed the title Thread reportOwnerLogin through canDeleteReportAction and merge eligibility Part 5- thread reportOwnerLogin through canDeleteReportAction and the merge predicates Oct 2, 2026
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@Krishna2323
Krishna2323 marked this pull request as ready for review October 2, 2026 11:30
@Krishna2323
Krishna2323 requested review from a team as code owners October 2, 2026 11:30
@melvin-bot
melvin-bot Bot requested review from DylanDylann and flaviadefaria and removed request for a team October 2, 2026 11:30
@melvin-bot

melvin-bot Bot commented Oct 2, 2026

Copy link
Copy Markdown

@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]

…6413/part-4a

# Conflicts:
#	src/hooks/useSearchBulkActions.ts
#	src/libs/ReportSecondaryActionUtils.ts
#	src/libs/ReportUtils.ts
#	src/libs/SearchUIUtils.ts
#	src/pages/inbox/report/ContextMenu/BaseReportActionContextMenu.tsx
#	src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx
#	tests/unit/ReportUtilsTest.ts
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@Krishna2323

Copy link
Copy Markdown
Contributor Author

@DylanDylann friendly bump

@DylanDylann

Copy link
Copy Markdown
Contributor

@MelvinBot Can you review this PR?

@MelvinBot

Copy link
Copy Markdown
Contributor

I found no blocking issues. The threading is correct, every caller is updated, and CI passes. I have three non-blocking suggestions.

  1. No test checks that callers pass the login on. Every updated test passes undefined as the owner login, so the new parameter never carries a value in them (example). If a caller dropped the login, the store fallback would hide it. Add one test where personalDetails holds the owner, and assert the login reaches isMoneyRequestReportEligibleForMerge or canDeleteMoneyRequestReport.
  2. canMergeReports depends on callers resolving the right owner. Both callers look up the owner of selectedReports.at(0) themselves (ReportUtils.ts:14603). It's correct today. Passing personalDetails and resolving the owner from firstSelectedReport inside the function would remove that dependency. This one is optional.
  3. PR body and TODOs. "Explanation of Change" and "PROPOSAL" are empty. The TODOs also use two naming schemes, "Part N" and "PR B2" (ReportUtils.ts:1800). Explain the series plan in the linked issue so later readers can follow it.
What I checked
  • Callers: All callers of canDeleteMoneyRequestReport, canDeleteReportAction, isMoneyRequestReportEligibleForMerge, canMergeReports, isMergeAction, isMergeActionForSelectedTransactions, shouldShowDeleteOption, and getTransactionsForMergingLocally pass the new argument in the right position.
  • Context-menu delete: The login comes from the narrowed reportID. For a report preview, that is childReportID, which is the same report canDeleteReportAction checks.
  • Secondary actions: submitterLogin and parentReportOwnerLogin already hold the report owner's login, so reusing them for delete and merge is correct.
  • Empty login: Treating '' as unresolved in isAwaitingFirstLevelApproval is sound, and the new unit tests cover it.
  • Merge list effect: The new personalDetails dependency in MergeTransactionsListContent is guarded by the eligibleTransactions check, so it won't refetch once data has loaded.
  • Manual testing: I reviewed the code only. I did not run the multi-account approval-chain steps in the app.

@DylanDylann

Copy link
Copy Markdown
Contributor

@Krishna2323 And please resolve conflict

…6413/part-4a

# Conflicts:
#	src/hooks/useSearchBulkActions.ts
#	src/libs/ReportUtils.ts
#	src/libs/actions/IOU/ReportWorkflow.ts
#	src/pages/Search/SearchReportsMergeReports.tsx
#	tests/unit/ReportUtilsTest.ts
…ng tests

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@DylanDylann

Copy link
Copy Markdown
Contributor

@Krishna2323 Can you resolve conflict?

…6413/part-4a

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@Krishna2323

Copy link
Copy Markdown
Contributor Author

@DylanDylann resolved

@melvin-bot
melvin-bot Bot requested a review from danieldoglas October 15, 2026 02:18
danieldoglas
danieldoglas previously approved these changes Oct 15, 2026
@danieldoglas

Copy link
Copy Markdown
Contributor

conflicts again. This PR is too big, it might be a challenge to merge it.

…6413/part-4a

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@Krishna2323

Copy link
Copy Markdown
Contributor Author

@danieldoglas conflicts resolved

@DylanDylann

Copy link
Copy Markdown
Contributor

@Krishna2323 conflicts again

…6413/part-4a

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
@Krishna2323

Copy link
Copy Markdown
Contributor Author

@DylanDylann @danieldoglas conflicts resolved 🙇🏻

@danieldoglas
danieldoglas merged commit 496ab3a into Expensify:main Oct 21, 2026
34 of 35 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

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

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/danieldoglas in version: 9.5.16-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update is needed. This PR is an internal refactor: it passes the report owner's login into the existing Delete and Merge eligibility checks instead of reading it from global data, so the user-facing rules for when Delete and Merge appear stay the same.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/danieldoglas in version: 9.5.18-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed. This PR is an internal refactor: it passes the report owner's login into the existing Delete and Merge permission checks instead of reading it from Onyx.connect, so who can delete or merge reports stays the same for users.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/grgia in version: 9.5.18-1 🚀

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