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.
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
There was a problem hiding this comment.
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.
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.
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 |
ntdiary
left a comment
There was a problem hiding this comment.
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.
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.
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
mountiny
left a comment
There was a problem hiding this comment.
@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 : ''; |
| const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${iouTransactionID || CONST.DEFAULT_NUMBER_ID}`); | ||
| const isCardTransaction = isCardTransactionTransactionUtils(transaction); | ||
|
|
||
| const shouldShowDeleteButton = |
There was a problem hiding this comment.
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 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))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
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