-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Show action badge in LHN for individual expense reports #88294
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
Changes from all commits
8bacd49
0a1b5e9
929354c
43807f3
8175249
ed33f18
4a7abb8
992bea5
03dd25b
e5e741a
c21a833
a5688ea
56f19b9
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 |
|---|---|---|
|
|
@@ -262,6 +262,39 @@ function canSubmitReport( | |
| ); | ||
| } | ||
|
|
||
| function getBadgeFromIOUReport( | ||
|
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. @MelvinBot add unit test for this function
Contributor
Author
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. Added 3 unit tests for
Contributor
Author
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. Added unit tests for |
||
| iouReport: OnyxEntry<OnyxTypes.Report>, | ||
| chatReport: OnyxEntry<OnyxTypes.Report>, | ||
| policy: OnyxEntry<OnyxTypes.Policy>, | ||
| reportMetadata: OnyxEntry<OnyxTypes.ReportMetadata>, | ||
| invoiceReceiverPolicy: OnyxEntry<OnyxTypes.Policy>, | ||
| ): ValueOf<typeof CONST.REPORT.ACTION_BADGE> | undefined { | ||
| // Show to the actual payer, or to policy admins via the pay-elsewhere path for negative expenses | ||
| if ( | ||
| canIOUBePaid(iouReport, chatReport, policy, undefined, undefined, undefined, undefined, invoiceReceiverPolicy) || | ||
| canIOUBePaid(iouReport, chatReport, policy, undefined, undefined, true, undefined, invoiceReceiverPolicy) | ||
| ) { | ||
| return CONST.REPORT.ACTION_BADGE.PAY; | ||
| } | ||
| if (canApproveIOU(iouReport, policy, reportMetadata)) { | ||
| return CONST.REPORT.ACTION_BADGE.APPROVE; | ||
| } | ||
| const isWaitingSubmitFromCurrentUser = canSubmitAndIsAwaitingForCurrentUser( | ||
| iouReport, | ||
| chatReport, | ||
| policy, | ||
| getReportTransactions(iouReport?.reportID), | ||
| getAllTransactionViolations(), | ||
| getCurrentUserEmail(), | ||
| getUserAccountID(), | ||
| getAllReportActions(iouReport?.reportID), | ||
| ); | ||
| if (isWaitingSubmitFromCurrentUser) { | ||
| return CONST.REPORT.ACTION_BADGE.SUBMIT; | ||
| } | ||
| return undefined; | ||
| } | ||
|
|
||
| function getIOUReportActionWithBadge( | ||
| chatReport: OnyxEntry<OnyxTypes.Report>, | ||
| policy: OnyxEntry<OnyxTypes.Policy>, | ||
|
|
@@ -276,30 +309,9 @@ function getIOUReportActionWithBadge( | |
| return false; | ||
| } | ||
| const iouReport = getReportOrDraftReport(action.childReportID); | ||
| // Show to the actual payer, or to policy admins via the pay-elsewhere path for negative expenses | ||
|
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. @MelvinBot restore this comment in new
Contributor
Author
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. Restored the comment:
Contributor
Author
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. Restored — the comment is at line 272 in the new |
||
| if ( | ||
| canIOUBePaid(iouReport, chatReport, policy, undefined, undefined, undefined, undefined, invoiceReceiverPolicy) || | ||
| canIOUBePaid(iouReport, chatReport, policy, undefined, undefined, true, undefined, invoiceReceiverPolicy) | ||
| ) { | ||
| actionBadge = CONST.REPORT.ACTION_BADGE.PAY; | ||
| return true; | ||
| } | ||
| if (canApproveIOU(iouReport, policy, reportMetadata)) { | ||
| actionBadge = CONST.REPORT.ACTION_BADGE.APPROVE; | ||
| return true; | ||
| } | ||
| const isWaitingSubmitFromCurrentUser = canSubmitAndIsAwaitingForCurrentUser( | ||
| iouReport, | ||
| chatReport, | ||
| policy, | ||
| getReportTransactions(iouReport?.reportID), | ||
| getAllTransactionViolations(), | ||
| getCurrentUserEmail(), | ||
| getUserAccountID(), | ||
| getAllReportActions(iouReport?.reportID), | ||
| ); | ||
| if (isWaitingSubmitFromCurrentUser) { | ||
| actionBadge = CONST.REPORT.ACTION_BADGE.SUBMIT; | ||
| const badge = getBadgeFromIOUReport(iouReport, chatReport, policy, reportMetadata, invoiceReceiverPolicy); | ||
| if (badge) { | ||
| actionBadge = badge; | ||
| return true; | ||
| } | ||
| return false; | ||
|
|
@@ -1740,6 +1752,7 @@ export { | |
| canSubmitReport, | ||
| canUnapproveIOU, | ||
| determineIouReportID, | ||
| getBadgeFromIOUReport, | ||
| getIOUReportActionWithBadge, | ||
| getReportOriginalCreationTimestamp, | ||
| reopenReport, | ||
|
|
||
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.
@MelvinBot add unit test