-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Show/hide delete expense button based on Liability type for card transaction #56877
Show/hide delete expense button based on Liability type for card transaction #56877
Conversation
src/pages/ReportDetailsPage.tsx
Outdated
const isCardTransaction = isCardTransactionTransactionUtils(transaction); | ||
|
||
const isAllowToDeleteTransaction = !isCardTransaction || (isCardTransaction && transaction?.comment?.liabilityType === CONST.TRANSACTION.LIABILITY_TYPE.ALLOW); | ||
const shouldShowDeleteButton = isCardTransaction ? isAllowToDeleteTransaction : shouldShowTaskDeleteButton || canDeleteRequest; |
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.
looks like the condition here is actually isCardTransaction ? transaction?.comment?.liabilityType === CONST.TRANSACTION.LIABILITY_TYPE.ALLOW : shouldShowTaskDeleteButton || canDeleteRequest
?
BTW, should we also update the Delete expense
option in the context menu? or address that in a separate issue?

might need to add some similar logic here as well.
Lines 2168 to 2181 in 5c4dc1c
if (isMoneyRequestAction(reportAction)) { | |
// For now, users cannot delete split actions | |
const isSplitAction = getOriginalMessage(reportAction)?.type === CONST.IOU.REPORT_ACTION_TYPE.SPLIT; | |
if (isSplitAction) { | |
return false; | |
} | |
if (isActionOwner) { | |
if (!isEmptyObject(report) && (isMoneyRequestReport(report) || isInvoiceReport(report))) { | |
return canDeleteTransaction(report); | |
} | |
return true; | |
} |
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.
Yes i think we should update the logic there and the logic on Search page too - you can also delete expense from there
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.
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.
@mountiny updated all places
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.
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.
@ntdiary @narefyev91 yes
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.
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.
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.
if BE already knows that transaction type will be corporate - i think the flag canDelete
should also follows the same pattern. @mountiny do you think it will be possible to add check on BE side?
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.
Ok, I personally agree that it’s better for the backend to return the correct value and keep it as the source of truth. :)
@narefyev91 please add test steps for all the places the expense can be deleted from @ntdiary please proceed with testing and checklist now |
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.
just FYI, if the client doesn't load the child IOU action data, moneyRequestAction
might be undefined
. And I think this problem can be handled in a separate ticket, as there doesn’t seem to be a good way to address it at the moment.
@narefyev91, also needs to add |
Reviewer Checklist
Screenshots/VideosAndroid: Native56877-android-native.movAndroid: mWeb Chrome56877-android-web.moviOS: Native56877-ios-native.moviOS: mWeb Safari56877-ios-safari.movMacOS: Chrome / Safari56877-mac-chrome.movMacOS: Desktop56877-mac-desktop.mov |
const isActionOwner = reportAction?.actorAccountID === currentUserAccountID; | ||
const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`] ?? null; | ||
const iouTransactionID = isMoneyRequestAction(reportAction) ? getOriginalMessage(reportAction)?.IOUTransactionID : ''; |
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.
Not a blocker, just feel that if we can move this below isMoneyRequestAction(reportAction)
, it could help us avoid some unnecessary fetches. I'll start filling the checklist in a few hours. :)
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.
@narefyev91 might be good to follow up later
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.
LGTM. And we might need to update the test steps based on this conv. The Delete
option is now directly tied to the liabilityType
in the transaction, not the feed settings. :D
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.
@narefyev91 the comments are NAB and I would like to get this fixed sooner, can you though follow up in some future PR to clean the NABs up? thanks!
const isActionOwner = reportAction?.actorAccountID === currentUserAccountID; | ||
const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`] ?? null; | ||
const iouTransactionID = isMoneyRequestAction(reportAction) ? getOriginalMessage(reportAction)?.IOUTransactionID : ''; |
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.
@narefyev91 might be good to follow up later
const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${iouTransactionID || CONST.DEFAULT_NUMBER_ID}`); | ||
const isCardTransaction = isCardTransactionTransactionUtils(transaction); | ||
|
||
const shouldShowDeleteButton = |
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.
Could you also wrap the (!isCardTransaction || (isCardTransaction && transaction?.comment?.liabilityType === CONST.TRANSACTION.LIABILITY_TYPE.ALLOW))
condition to some helper method or variable? I feel like this is hard to read and its used in at least two places
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/mountiny in version: 9.1.10-0 🚀
|
Confirmed! |
This case is not working. No option to delete transactions if 2025-03-10_14-30-06.mp4 |
Still checked this off as IDT it needs to block deploy. |
🚀 Deployed to production by https://github.com/mountiny in version: 9.1.10-6 🚀
|
There was a BE issue preventing the delete case from working. We fixed it and retested, and it's working now! |
There are still some issues on the FE that need to be resolved. |
Explanation of Change
Liability type are currently coming for card transactions. We should show Delete expense button based on this prop
Fixed Issues
$ #56366
PROPOSAL: #56366 (comment)
Tests
Verify additional places:
Context menu button:
Verify additional places:
Context menu button:
Offline tests
No changes
QA Steps
Same as tests
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
android.mov
Android: mWeb Chrome
android-web.mov
iOS: Native
ios.mov
iOS: mWeb Safari
ios-web.mov
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov