Improve creating expenses on Collect with Instant Submit#36388
Conversation
|
@hoangzinh Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
@hoangzinh Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
| let oneOnOneIOUReport: OneOnOneIOUReport = oneOnOneChatReport.iouReportID ? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${oneOnOneChatReport.iouReportID}`] : null; | ||
| const shouldCreateNewOneOnOneIOUReport = | ||
| !oneOnOneIOUReport || (isOwnPolicyExpenseChat && ReportUtils.isControlPolicyExpenseReport(oneOnOneIOUReport) && ReportUtils.isReportApproved(oneOnOneIOUReport)); | ||
| !oneOnOneIOUReport || (isOwnPolicyExpenseChat && ReportUtils.isPaidGroupPolicy(oneOnOneIOUReport) && ReportUtils.isReportApproved(oneOnOneIOUReport)); |
There was a problem hiding this comment.
Just wanna double check whether we should use ReportUtils.isPaidGroupPolicyExpenseReport instead of ReportUtils.isPaidGroupPolicy here.
There was a problem hiding this comment.
Just wanna double check whether we should use ReportUtils.isPaidGroupPolicyExpenseReport instead of ReportUtils.isPaidGroupPolicy here.
It doesn't really matter, both should work fine.
| const isOwnExpenseReport = isExpenseReport(report) && isOwnPolicyExpenseChat; | ||
| if (isOwnExpenseReport && PolicyUtils.isPaidGroupPolicy(policy)) { | ||
| return isDraftExpenseReport(report); | ||
| return isDraftExpenseReport(report) || (PolicyUtils.isInstantSubmitEnabled(policy) && isProcessingReport(report)); |
There was a problem hiding this comment.
Hi @youssef-lr is there any doc that helps me verify this logic? Or can you help to leave a comment in code to explain it? Thanks
There was a problem hiding this comment.
I can add a comment. There is a doc, but I think you might not have access to it.
There was a problem hiding this comment.
I think this comment already explains this logic. If Instant Submit is turned on, we can add expenses to an already submitted report. If reporting frequency is set to 'Weekly', then we can only add expenses to draft reports (i.e. not submitted yet).
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-02-27.at.15.27.22.android.mp4Android: mWeb ChromeScreen.Recording.2024-02-27.at.17.05.29.android.chrome.mp4iOS: NativeScreen.Recording.2024-02-27.at.17.10.25.ios.1.mp4Screen.Recording.2024-02-27.at.17.12.49.ios.2.moviOS: mWeb SafariScreen.Recording.2024-02-27.at.17.32.42.ios.safari.movMacOS: Chrome / SafariScreen.Recording.2024-02-26.at.23.50.05.web.mp4Screen.Recording.2024-02-27.at.14.42.59.web.manual.scan.movScreen.Recording.2024-02-27.at.14.45.04.web.distance.mp4MacOS: DesktopScreen.Recording.2024-02-27.at.15.02.30.desktop.mp4 |
|
friendly bump @hoangzinh |
|
@youssef-lr sure, I'm complete recordings. Will try to complete it within today |
|
Thanks! |
|
@techievivek Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
Awesome thanks! All yours @Beamanator! |
|
Not sure why you got assigned @techievivek, Alex is on this :D |
| * - report is a draft | ||
| * - report is a processing expense report and its policy has Instant reporting frequency | ||
| */ | ||
| function canAddTransactionsToMoneyRequest(report: OnyxEntry<Report>): boolean { |
There was a problem hiding this comment.
NAB: Rename to canAddOrDeleteTransactionFromMoneyRequest or something like that so we don't have to add this comment // If the report supports adding transactions to it, then it also supports deleting transactions from it..
| const isFree = policy?.type === CONST.POLICY.TYPE.FREE; | ||
| const isInstantSubmitEnabled = PolicyUtils.isInstantSubmitEnabled(policy); | ||
|
|
||
| // Define the state and status of the report based on whether the policy is free or paid |
There was a problem hiding this comment.
We can remove this comment, or update it to match the new condition.
There was a problem hiding this comment.
I think the code is self-explanatory, so we can remove
|
Updated @rlinoz! I think Alex is OOO til Monday. He hasn't requested any changes or anything since his last review except that we need to test, so let's try to get this merged today! 🙏 |
| // For now, users cannot delete split actions | ||
| const isSplitAction = reportAction?.originalMessage?.type === CONST.IOU.REPORT_ACTION_TYPE.SPLIT; | ||
|
|
||
| if (isSplitAction || isSettled(String(reportAction?.originalMessage?.IOUReportID)) || (!isEmptyObject(report) && isReportApproved(report))) { |
There was a problem hiding this comment.
I removed this logic as it's already handled in canAddOrDeleteTransactions
| function canAddTransactionsToMoneyRequest(report: OnyxEntry<Report>): boolean { | ||
| if (!isIOUReport(report) && !isExpenseReport(report)) { | ||
| function canAddOrDeleteTransactions(moneyRequestReport: OnyxEntry<Report>): boolean { | ||
| if (!isMoneyRequest(moneyRequestReport)) { |
There was a problem hiding this comment.
isMoneyRequest only check for IOU reports, and I think this is making the button not show up inside the expense report (step 7 of the tests).
I think you will need to update this to use isMoneyRequestReport as well
| if (!isMoneyRequest(moneyRequestReport)) { | |
| if (!isMoneyRequest(moneyRequestReport) && !isMoneyRequestReport(moneyRequestReport)) { |
There was a problem hiding this comment.
This might fix the failing tests as well
There was a problem hiding this comment.
woops just a mistake, will update
There was a problem hiding this comment.
if (!isMoneyRequest(moneyRequestReport) && !isMoneyRequestReport(moneyRequestReport))
It should only be isMoneyRequestReport here, because we can't add transactions to a transaction :D
|
Do you have |
|
I do, it is just a little slow sometimes |
|
My guess is you tried to submit when the pusher update marking the report as approved wasn't applied yet. Can you try approving, and waiting a bit until you see it was approved, then submit? |
Yeah we could explore this for cases where a pusher update is missed, but in production this scenario rarely happens. |
|
I think I got it: With
Screen.Recording.2024-03-07.at.12.34.56.movAnyway, it doesn't look related to this changes, so I think we are good here |
|
Weird @rlinoz, it gets updated for me in real time: Screen.Recording.2024-03-07.at.16.41.31.mov |
|
✋ 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/youssef-lr in version: 1.4.49-0 🚀
|
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.4.50-5 🚀
|

Details
Held on https://github.com/Expensify/Auth/pull/9916cc @Beamanator
Fixed Issues
$ #34955
Tests
autoReportingFrequencyset toinstant, if it doesn't, run the following in the policy page as the admin:const p = Policy.getCurrent(); p.policy.autoReportingFrequency = 'instant'; p.save();submitter@gmail.com.approver@gmail.comto the workspace, set it as the default approver.Request Money, click on it and make sure the request gets added to the current report.Offline tests
The same steps as above, except, go offline before requesting money, then go back online. Make sure everything looks right as described in the s
QA Steps
autoReportingFrequencyset toinstant, if it doesn't, run the following in the policy page as the admin:const p = Policy.getCurrent(); p.policy.autoReportingFrequency = 'instant'; p.save();submitter@gmail.com.approver@gmail.comto the workspace, set it as the default approver.Request Money, click on it and make sure the request gets added to the current report.PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)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: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2024-02-23.at.03.06.39.mov
MacOS: Desktop