-
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
Create Draft reports optimistically #32157
Conversation
…ts-migration/custom-dev-menu-component"" This reverts commit 23bfbf9.
@ 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] |
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.
In general, code looks good. I still need to run and test it.
🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪
|
@rezkiy37 thanks, updated |
@mountiny, that's how it works on my side. Create.Draft.reports.optimistically.mp4 |
@rezkiy37 thanks! for now, lets approve and reimburse/ mark as reimbursed from OldDot, the NewDot flow is also under construction |
const isFromPaidPolicy = policyType === CONST.POLICY.TYPE.TEAM || policyType === CONST.POLICY.TYPE.CORPORATE; | ||
const shouldShowNextSteps = isFromPaidPolicy && nextStep && !_.isEmpty(nextStep.message); |
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 is to ensure we show the next steps on any Paid policy expense report in any state/status not only as draft
stateNum, | ||
statusNum, |
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.
Adding statusNum too because Draft report is defined by having both state and status set to 0
|
||
// Definte the state and status of the report based on whether the policy is free or paid | ||
const state = isFree ? CONST.REPORT.STATE.SUBMITTED : CONST.REPORT.STATE.OPENED; | ||
const stateNum = isFree ? CONST.REPORT.STATE_NUM.PROCESSING : CONST.REPORT.STATE_NUM.OPEN; |
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.
Discussed elsewhere but I will make a follow up PR to clean up the naming mess of processing/ submitted states/ status, to make it all aligned
hasOutstandingIOU: false, | ||
hasOutstandingChildRequest: false, | ||
iouReportID: null, |
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.
The submitter does not have an outstanding child request anymore on the workspace chat even if they did not have one before.
removing the iouReportID
key ensure we wont try to create new transaction on processing report
Reviewer Checklist
Screenshots/VideosMacOS: Chrome / Safari32157-web.mp4 |
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.
Tests well.
@akinwale Added one small change to fix the report name of drafts |
src/libs/ReportUtils.ts
Outdated
/** | ||
* Checks if the supplied report is in Open state and status. | ||
*/ | ||
function isReportDraft(report: OnyxEntry<Report>): boolean { | ||
return isExpenseReport(report) && report?.stateNum === CONST.REPORT.STATE_NUM.OPEN && report?.statusNum === CONST.REPORT.STATUS.OPEN; | ||
} | ||
|
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 had to move this up so I can use the method in the getMoneyRequestReportName
src/libs/ReportUtils.ts
Outdated
@@ -1688,7 +1695,8 @@ function getMoneyRequestReportName(report: OnyxEntry<Report>, policy: OnyxEntry< | |||
return Localize.translateLocal('iou.payerSpentAmount', {payer: payerName, amount: formattedAmount}); | |||
} | |||
|
|||
if (!!report?.hasOutstandingIOU || moneyRequestTotal === 0) { | |||
// The report name should show as owed also for drafts | |||
if (!!report?.hasOutstandingIOU || isReportDraft(report) || moneyRequestTotal === 0) { |
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 feel like the !!report?.hasOutstandingIOU
is a bad pattern we got here, but not in scope to fix in this PR
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.
Some small feedback.
src/libs/ReportUtils.ts
Outdated
@@ -1688,7 +1695,8 @@ function getMoneyRequestReportName(report: OnyxEntry<Report>, policy: OnyxEntry< | |||
return Localize.translateLocal('iou.payerSpentAmount', {payer: payerName, amount: formattedAmount}); | |||
} | |||
|
|||
if (!!report?.hasOutstandingIOU || moneyRequestTotal === 0) { | |||
// The report name should show as owed also for drafts |
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 comment is a bit weird, since it only applies to one of the conditions below.
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 will remove it from there, I agree. The conditions are quite self-explanatory so we can go without it I this
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 will remove it from there, I agree. The conditions are quite self-explanatory so we can go without it I this
✋ 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 production by https://github.com/mountiny in version: 1.4.6-2 🚀
|
/** | ||
* Checks if the supplied report is an expense report in Open state and status. | ||
*/ | ||
function isDraftExpenseReport(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.
Just saw this method... why, oh, why did we introduce a new term draft
for what in every other place we call open
? 😢
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 followed the terminology used in the App so its clearer for external engineers who dont have context of the Open reports, however, I agree in the hindsight it would be better to follow the backend terminology and keep Drafts
as the marketing word only 👍
Details
**NOTE: pull latest Auth main and remake
When expense report is created on paid policy, its always created in Open state right now.
Also updates the report name for draft expense reports to say owes
Fixed Issues
$ #32174
Tests
Offline tests
N/A
QA Steps
Same as above
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)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
tested on web:
https://github.com/Expensify/App/assets/36083550/692bc2b8-8ae3-435f-a74d-bac73d7f5627
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop