-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
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] |
src/libs/actions/IOU.ts
Outdated
@@ -1728,7 +1735,7 @@ function createSplitsAndOnyxData( | |||
// For Control policy expense chats, if the report is already approved, create a new expense report | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wanna double check whether we should use ReportUtils.isPaidGroupPolicyExpenseReport
instead of ReportUtils.isPaidGroupPolicy
here.
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.
Just wanna double check whether we should use ReportUtils.isPaidGroupPolicyExpenseReport instead of ReportUtils.isPaidGroupPolicy here.
It doesn't really matter, both should work fine.
src/libs/ReportUtils.ts
Outdated
@@ -4255,7 +4255,7 @@ function canRequestMoney(report: OnyxEntry<Report>, policy: OnyxEntry<Policy>, o | |||
if (isMoneyRequestReport(report)) { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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).
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.
Thanks for clarifying @youssef-lr .
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! |
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.
LGTM
@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 |
src/libs/ReportUtils.ts
Outdated
* - 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
.
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.
True true, on it
src/libs/ReportUtils.ts
Outdated
@@ -2957,11 +2972,11 @@ function buildOptimisticExpenseReport(chatReportID: string, policyID: string, pa | |||
const formattedTotal = CurrencyUtils.convertToDisplayString(storedTotal, currency); | |||
const policy = getPolicy(policyID); | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove this comment, or update it to match the new condition.
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.
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! 🙏 |
@@ -1285,14 +1285,13 @@ function canDeleteReportAction(reportAction: OnyxEntry<ReportAction>, reportID: | |||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this logic as it's already handled in canAddOrDeleteTransactions
src/libs/ReportUtils.ts
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might fix the failing tests as well
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.
woops just a mistake, will update
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.
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
autoReportingFrequency
set 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();
[email protected]
.[email protected]
to 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
autoReportingFrequency
set 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();
[email protected]
.[email protected]
to 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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.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