-
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
Merged
mountiny
merged 21 commits into
Expensify:main
from
callstack-internal:hide-delete-expense-button-if-card-expense
Mar 5, 2025
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
e1586d2
Show/hide delete expense button based on feed settings for Company cards
narefyev91 b5600cd
Merge branch 'refs/heads/main' into hide-delete-expense-button-if-car…
narefyev91 ea2eb87
show/hide button based on transaction liability
narefyev91 db6e038
prettier
narefyev91 658078e
fix ts
narefyev91 f04c256
update condition
narefyev91 fb471bb
remove ability to show delete button in context menu
narefyev91 089e966
fix empty transaction
narefyev91 ba8fa7e
Merge branch 'refs/heads/main' into hide-delete-expense-button-if-car…
narefyev91 3cb14b6
fix jest
narefyev91 78a5666
fix jest
narefyev91 20f09c3
add unit test
narefyev91 5c5ffa0
show delete button for card transaction report
narefyev91 c60107a
update condition for report details page
narefyev91 1b4744c
update condition for context menu
narefyev91 5b32275
Merge branch 'refs/heads/main' into hide-delete-expense-button-if-car…
narefyev91 53e8d25
update after c+ review
narefyev91 0ef4703
prettier
narefyev91 e15f660
ts
narefyev91 dbca006
fix jest
narefyev91 2807ce8
add missing money request
narefyev91 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,7 @@ import { | |
shouldUseFullTitleToDisplay, | ||
} from '@libs/ReportUtils'; | ||
import StringUtils from '@libs/StringUtils'; | ||
import {isCardTransaction as isCardTransactionTransactionUtils} from '@libs/TransactionUtils'; | ||
import { | ||
canCancelPayment, | ||
cancelPayment as cancelPaymentAction, | ||
|
@@ -294,7 +295,14 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta | |
const shouldShowTaskDeleteButton = | ||
isTaskReport && !isCanceledTaskReport && canWriteInReport(report) && report.stateNum !== CONST.REPORT.STATE_NUM.APPROVED && !isClosedReport(report) && canModifyTask && canActionTask; | ||
const canDeleteRequest = isActionOwner && (canDeleteTransaction(moneyRequestReport) || isSelfDMTrackExpenseReport) && !isDeletedParentAction; | ||
const shouldShowDeleteButton = shouldShowTaskDeleteButton || canDeleteRequest; | ||
const iouTransactionID = isMoneyRequestAction(requestParentReportAction) ? getOriginalMessage(requestParentReportAction)?.IOUTransactionID : ''; | ||
|
||
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Could you also wrap the |
||
shouldShowTaskDeleteButton || (canDeleteRequest && (!isCardTransaction || (isCardTransaction && transaction?.comment?.liabilityType === CONST.TRANSACTION.LIABILITY_TYPE.ALLOW))); | ||
|
||
useEffect(() => { | ||
if (canDeleteRequest) { | ||
|
@@ -366,8 +374,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta | |
const shouldShowCancelPaymentButton = caseID === CASES.MONEY_REPORT && canCancelPayment(moneyRequestReport, session); | ||
const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${moneyRequestReport?.chatReportID}`); | ||
|
||
const iouTransactionID = isMoneyRequestAction(requestParentReportAction) ? getOriginalMessage(requestParentReportAction)?.IOUTransactionID : ''; | ||
|
||
const cancelPayment = useCallback(() => { | ||
if (!chatReport) { | ||
return; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
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