[No QA] Implement report primary action getter#57475
Conversation
|
@ikevin127 let's prioritize reviewing this PR! |
luacmartins
left a comment
There was a problem hiding this comment.
Looking good. Left a few comments.
src/libs/ReportPrimaryActionUtils.ts
Outdated
| policy: Policy, | ||
| reportTransactions: Transaction[], | ||
| violations: OnyxCollection<TransactionViolation[]>, | ||
| ): ValueOf<typeof CONST.REPORT.PRIMARY_ACTIONS> | undefined { |
There was a problem hiding this comment.
From the design doc, looks like the return type of this function should be:
ValueOf(typeof CONST.REPORT.PRIMARY_ACTIONS) | ''which means that if there's no match, we should return empty string (from design doc):
// If there is no Primary action to return for this report, just return an empty string default return '';```
If there's an already agreed-upon reason for which we want undefined instead of empty string then this comment can be ignored.
There was a problem hiding this comment.
Ah yea, nice catch. We can update it to return an empty string
|
Looks like we're missing this part from the doc:
and this part:
If this is expected for this PR, then we're good to move forward 👍 |
|
@ikevin127 this parts you mentioned above will be done as a separate PR once the logic for secondary/preview actions are ready as well. |
ikevin127
left a comment
There was a problem hiding this comment.
@ikevin127 this parts you #57475 (comment) will be done as a separate PR once the logic for secondary/preview actions are ready as well.
Based on this, the changes LGTM 🚀
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
luacmartins
left a comment
There was a problem hiding this comment.
I left some comments that I think need to be addressed
|
@luacmartins I applied suggestions 🫡 |
|
✋ 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/luacmartins in version: 9.1.9-0 🚀
|
|
🚀 Deployed to staging by https://github.com/luacmartins in version: 9.1.9-0 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 9.1.9-8 🚀
|
| function isApproveAction(report: Report, policy: Policy, reportTransactions: Transaction[]) { | ||
| const isExpense = isExpenseReport(report); | ||
| const isApprover = isApprovedMember(policy, getCurrentUserAccountID()); | ||
| const isApprovalEnabled = policy.approvalMode && policy.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL; | ||
|
|
||
| if (!isExpense || !isApprover || !isApprovalEnabled) { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
You don't need to be the current approver to approve a report.
If you are an approver and got a report to approve, and then you are no longer the workspace approver, then you'd still have access to the previous submitted report and you can still approve it.
Coming from #61389
| const isProcessing = isProcessingReport(report); | ||
| const isOneExpenseReportOnHold = isOneExpenseReport && isOnHold; | ||
|
|
||
| if (isProcessing || isOneExpenseReportOnHold) { |
There was a problem hiding this comment.
This(isOneExpenseReportOnHold) seems to be an incorrect condition to derive an approve action which caused an issue #65873
| } | ||
|
|
||
| const isExporter = isPrefferedExporter(policy); | ||
| if (!isExporter) { |
There was a problem hiding this comment.
We should have also checked whether the current user is an admin or not. Only checking for Preferred Exporter caused this issue. The export option wasn’t shown to the admin because we were only checking for !isExporter.
@luacmartins
Explanation of Change
This PR implements logic responsible for getting primary action button that will be used in
MoneyReportHeaderFixed Issues
$ #57436
PROPOSAL: N/A
Tests
Verify that
npm run testpassesOffline tests
N/A
QA Steps
N/A
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
No UI changes
Android: mWeb Chrome
No UI changes
iOS: Native
No UI changes
iOS: mWeb Safari
No UI changes
MacOS: Chrome / Safari
No UI changes
MacOS: Desktop
No UI changes