-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix: prevent Move expense from appearing on forwarded reports #83146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
3396f8d
42ba7bd
aa7fc53
9858fd0
7ba659f
ad73acd
3c13bf7
922cb3c
884406b
4c38602
083b5a4
cb25709
474dc73
ac2eb6f
d72e2e2
d1a9149
7405c95
e91470f
2f201b7
9b09039
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,44 @@ | ||||||||||||||||||||||||
| import type {SelectedTransactions} from './types'; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| type SearchMoveSelectionValidationParams = { | ||||||||||||||||||||||||
| isExpenseReportSearch?: boolean; | ||||||||||||||||||||||||
| getOwnerAccountIDForReportID?: (reportID?: string) => number | undefined; | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| type SearchMoveSelectionValidation = { | ||||||||||||||||||||||||
| canMoveToReport: boolean; | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| function getSearchMoveSelectionValidation( | ||||||||||||||||||||||||
| selectedTransactions: SelectedTransactions, | ||||||||||||||||||||||||
| {isExpenseReportSearch = false, getOwnerAccountIDForReportID}: SearchMoveSelectionValidationParams = {}, | ||||||||||||||||||||||||
| ): SearchMoveSelectionValidation { | ||||||||||||||||||||||||
| const selectedTransactionEntries = Object.values(selectedTransactions); | ||||||||||||||||||||||||
| const hasSelections = selectedTransactionEntries.length > 0; | ||||||||||||||||||||||||
| const hasOnlyTransactionSelections = selectedTransactionEntries.every((transaction) => transaction.transaction?.transactionID !== undefined); | ||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The old logic doesn't have to check this |
||||||||||||||||||||||||
| const canAllTransactionsBeMoved = hasSelections && selectedTransactionEntries.every((transaction) => transaction.canChangeReport); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const ownerAccountIDs = new Set<number>(); | ||||||||||||||||||||||||
| let hasUnknownOwner = false; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| for (const transaction of selectedTransactionEntries) { | ||||||||||||||||||||||||
| const ownerAccountID = transaction.ownerAccountID ?? transaction.report?.ownerAccountID ?? getOwnerAccountIDForReportID?.(transaction.reportID); | ||||||||||||||||||||||||
| if (typeof ownerAccountID === 'number') { | ||||||||||||||||||||||||
| ownerAccountIDs.add(ownerAccountID); | ||||||||||||||||||||||||
| if (ownerAccountIDs.size > 1) { | ||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| hasUnknownOwner = true; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const hasMultipleOwners = ownerAccountIDs.size > 1 || (hasUnknownOwner && (ownerAccountIDs.size > 0 || selectedTransactionEntries.length > 1)); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||
| canMoveToReport: hasSelections && hasOnlyTransactionSelections && canAllTransactionsBeMoved && !hasMultipleOwners && !isExpenseReportSearch, | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
|
Comment on lines
+39
to
+41
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can only export canMoveToReport if we only use this value at the moment
Suggested change
|
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| export default getSearchMoveSelectionValidation; | ||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mavrickdeveloper why do we need this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So i needed getSearchMoveSelectionValidation() because this PR also fixes bulk-move menu/route drift.
During testing, i found the bulk menu and the RHP were applying different checks, so preserved/direct navigation could still expose Move for invalid selections. This helper centralizes the move-selection contract so both surfaces enforce the same rules , only transaction rows, every item must have
canChangeReport, all items must belong to one owner, and the search must not be an expense-report search , thoughts?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate your effort here. Do you have a recording to visualize this issue, " this PR also fixes bulk-move menu/route drift."? TY
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here you go , lmk if anything is unclear
2026-04-03.15-13-07.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our PR state for Bulk select & route drift :
2026-04-03.16-12-35.mp4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hoangzinh can you please confirm if we should revert the bulk/snapshot fix because that mismatch is mentioned in the issue OP in the actual result (Appears to fail when the BE provides a response to acknowledge that expenses can't be moved off an approved report.)
so the wrong move appearance in bulk select is actually a reported issue , but the route drift is not
lmk what you think
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate on it, please? The expectation of the original issue is that we shouldn't show "Moving report" in bulk select. Route drift (or direct access) is not what a normal user will do.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hoangzinh yes then we should keep the bulk fix , my last commit fixes 2 part , Move action appearance in action button before BE hydration + route drift
we should revert the route drift issue only , because it is not explicitly mentioned in the OP , but we should keep the bulk menu fix , this :
2026-04-06.16-01-43.mp4
if you look closely staging is wrongly showing move report vs our fix which is correctly blocking it before and after hydration which is included in the issue expected/actual behavior
We should preserve this fix behavior , we are on same page right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes, we should only revert the route drift issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mavrickdeveloper just wanna confirm, after revert, will we only have code related to your proposal here? #79602 (comment)