Skip to content
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

fix: change message when reimbursementChoice is reimburseNo #49837

Conversation

koko57
Copy link
Contributor

@koko57 koko57 commented Sep 27, 2024

Details

Fixed Issues

$ #49333
PROPOSAL:

Tests

  1. Go to Workspace -> enable Workflows.
  2. Disable payments
  3. Submit an expense on the workspace chat
  4. Go offline, click into the expense
  5. Verify that you see "No further action required" text in the header.
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  1. Go to Workspace -> enable Workflows.
  2. Disable payments
  3. Submit an expense on the workspace chat
  4. Go offline, click into the expense
  5. Verify that you see "No further action required" text in the header.
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • If we are not using the full Onyx data that we loaded, I've added the proper selector in order to ensure the component only re-renders when the data it is using changes
      • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari Screenshot 2024-09-27 at 17 15 06
MacOS: Desktop

@koko57 koko57 requested a review from a team as a code owner September 27, 2024 10:29
@melvin-bot melvin-bot bot requested a review from ikevin127 September 27, 2024 10:29
Copy link

melvin-bot bot commented Sep 27, 2024

@ikevin127 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]

@ikevin127
Copy link
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: Native android
Android: mWeb Chrome android-mweb
iOS: Native ios
iOS: mWeb Safari ios-mweb
MacOS: Chrome / Safari web
MacOS: Desktop desktop

Copy link
Contributor

@ikevin127 ikevin127 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@koko57 I just completed the reviewer checklist, it tests well following the test steps provided in description, except for the case when the step is replaced by the OpenReportresponse if we visit the report while online.

web-to-clarify.mov

I noticed in the issue #49333 (comment) that @srikarparsi said:

Ah thanks for the looking into this. Do you think you could help with the offline (optimistic) behavior here and I can work on a backend PR that returns the right next steps for this case?

So I guess we're good to go here since the back-end PR will fix this case once it's live 👍

@melvin-bot melvin-bot bot requested a review from srikarparsi September 28, 2024 01:49
@srikarparsi
Copy link
Contributor

Hm, I actually envisioned the implementation for this to be a little different. I'm sorry for not clarifying this earlier.

When an expense is submitted when reimbursementChoice is reimburseNo, the backend sets the status of the report to CLOSED. And it looks like the next steps of an optimistically closed report is already "No further action required".

So, when a report is created with reimbursementChoice = reimburseNo, I believe we just have to set the status of the report to `CLOSED and that should take care of the next steps. I still do like how you created a separate variable for noActionRequired to consolidate the three usages so I think we can keep that.

But to clarify the backend behavior we need to emulate is:

If a report is on a workspace with:

Then the report should optimistically be created with:

  • Status = CLOSED (2)
  • State = APPROVED (2)

For internal reference, this is the Auth code which is based on @trjExpensify's comment.

@trjExpensify
Copy link
Contributor

trjExpensify commented Sep 30, 2024

When an expense is submitted when reimbursementChoice is reimburseNo, the backend sets the status of the report to CLOSED

Hm, why? It's totally possible to have approvals enabled and no payments, so the report would be approved and shouldn't be changed to closed.

So, when a report is created with reimbursementChoice = reimburseNo, I believe we just have to set the status of the report to `CLOSED and that should take care of the next steps.

I don't think we should be doing that if the workspace has approvals enabled. @koko57's issue (as I understand it) is fixing the next steps for the case where an expense report is done and "no further action is required" which can be possible when the report is either closed or approved depending on the workspace settings.

@koko57
Copy link
Contributor Author

koko57 commented Sep 30, 2024

@srikarparsi @trjExpensify so should I do anything here? I will change the check I used for arePaymentsEnabled but should I do anything else then?

@trjExpensify
Copy link
Contributor

@srikarparsi @trjExpensify so should I do anything here?

That probably depends, need to see what @srikarparsi has to say about #49837 (comment).

@srikarparsi
Copy link
Contributor

Hey! In the first part of this comment, I generalized a bit to try to explain the implementation approach (the part about reimburseChoice = no leads to closed reports).

I tried to explain the behavior in detail with the second part:

But to clarify the backend behavior we need to emulate is:

If a report is on a workspace with:

Then the report should optimistically be created with:

  • Status = CLOSED (2)
  • State = APPROVED (2)

For internal reference, this is the Auth code which is based on @trjExpensify's comment.

Do you agree with the second part @trjExpensify? Basically, if the three conditions are met (payments disabled, submit&close approval and instant submit), then the report should be created in the closed state. I believe that is the behavior we ended up with on this issue but please correct me if I'm wrong.

@trjExpensify
Copy link
Contributor

Do you agree with the second part @trjExpensify? Basically, if the three conditions are met (payments disabled, submit&close approval and instant submit), then the report should be created in the closed state

Yes, I agree with that. I'm confused by this mismatch with the matrix though, was that a typo on state?:

Then the report should optimistically be created with:

Status = CLOSED (2)
State = APPROVED (2)

image

@srikarparsi
Copy link
Contributor

Yes, I agree with that. I'm confused by this mismatch with the matrix though, was that a typo on state?:

Yeahh, the matrix is a little confusing when compared with code. 2(status) and 2(state) in the matrix correlates with the closed reports and that's what we're using in the Auth and will be using in the App code.

I just said

Status = CLOSED (2)
State = APPROVED (2)

because in the App code, state 2 is called APPROVED

@trjExpensify
Copy link
Contributor

because in the App code, state 2 is called APPROVED

Okay, as if it wasn't confusing enough 😂

@trjExpensify
Copy link
Contributor

So we good to move on here?

@srikarparsi
Copy link
Contributor

Yupp, I believe so. @koko57 do you think you could switch the implementation to this comment? Specifically this part:

But to clarify the backend behavior we need to emulate is:

If a report is on a workspace with:

Then the report should optimistically be created with:

  • Status = CLOSED (2)
  • State = APPROVED (2)

For internal reference, this is the Auth code which is based on @trjExpensify's comment.

Once again, sorry for not clarifying this earlier.

@koko57
Copy link
Contributor Author

koko57 commented Oct 2, 2024

@srikarparsi I see that we have this in submitReport
Screenshot 2024-10-02 at 14 52 41

@koko57
Copy link
Contributor Author

koko57 commented Oct 3, 2024

@srikarparsi what should I change on my side then?

@srikarparsi
Copy link
Contributor

So for these reports, with these conditions, we won't actually ever hit the SubmitReport function because the workspace is on InstantSubmit. You can test this by going offline and then creating an expense report in a policy with payments disabled, instant submit, and no approvals:

Settings screenshot:
image

When you create an expense report in offline mode in this policy, the report is created in 1 state and 1 status:
image

But this report should optimistically be created in state 2 and status 2 if these conditions are met. It looks like the optimistic data for the RequestMoney function is built here so we just need to modify the report to be 2 state 2 status (kind of like how it was done for RequestMoney but with the above conditions)

@koko57
Copy link
Contributor Author

koko57 commented Oct 7, 2024

@srikarparsi thanks for explanation! I was a bit confused with this one. I think I've finally made this work - I needed to create a new function to get stateNum and statusNum for the expense report.
Screenshot 2024-10-07 at 19 28 00

@ikevin127
Copy link
Contributor

@koko57 Is the PR ready to be retested ?

@koko57
Copy link
Contributor Author

koko57 commented Oct 9, 2024

@ikevin127 yes, it's ready to be retested

cc @srikarparsi

@ikevin127
Copy link
Contributor

I went through the testing steps again, same flow I followed before in #49837 (review) and the behaviour changed to:

  1. 🟢 Following the current description Tests steps -> all are passing.

  2. ⚠️ Upon returning back online, the No further action required! goes away (see video below), is this the correct behaviour ?

    Video
    bideo.mov
  3. ⚠️ In NextStepUtils.ts -> noActionRequired object I noticed that No further action required! is not translated - which I think should be, right ? I dropped a review comment here.

cc @srikarparsi To verify if everything is good / needs changes.

case CONST.REPORT.STATUS_NUM.CLOSED:
optimisticNextStep = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add optimisticNextStep = noActionRequired and the break. I think it would improve readability a little.

@srikarparsi
Copy link
Contributor

cc @srikarparsi To verify if everything is good / needs changes.

The No further action required! disappearing after online is backend as @koko57 pointed out here.

And for the translation, I'm getting confirmation internally and will leave a comment with the correct translation.

Thanks for pointing these out!

@@ -125,6 +135,12 @@ function buildNextStep(report: OnyxEntry<Report>, predictedNextStatus: ValueOf<t
],
};

if (!PolicyUtils.arePaymentsEnabled(policy)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry one more thing, @koko57 do you think you could explain why you added this? If payments are disabled and there is some non instant auto reporting frequency (weekly, monthly, etc.), the next steps should still be "Waiting for x's expenses to automatically submit" (below text). cc @trjExpensify for confirmation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A delayed submission frequency other than manually, yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@srikarparsi I understood that it also must be that way. So I will remove it

@koko57
Copy link
Contributor Author

koko57 commented Oct 11, 2024

@srikarparsi changes reverted

Copy link
Contributor

@srikarparsi srikarparsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, this looks good, thank you!

@srikarparsi srikarparsi merged commit b7c1e1e into Expensify:main Oct 11, 2024
16 checks passed
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

Copy link
Contributor

🚀 Deployed to staging by https://github.com/srikarparsi in version: 9.0.49-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@IuliiaHerets
Copy link

This PR is failing because of issue #50785

Copy link
Contributor

🚀 Deployed to production by https://github.com/marcaaron in version: 9.0.49-2 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants