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

Remove the dependency on the parent report when deciding if report can be approved #47926

Merged
merged 2 commits into from
Aug 28, 2024

Conversation

mountiny
Copy link
Contributor

@mountiny mountiny commented Aug 23, 2024

Details

The IOU.canApproveIOU method relies on the parent report chat to determine if the report can be approved or not. This is a problem because approvers of expense reports might not necessarily have access to the parent report, or the parent report might not be loaded in local Onyx state, which leads to a bug whereas the approver can't see the approve button.

Luckily we know all the information we need to show the button from the expense report and the policy of the report which the user should have locally.

Fixed Issues

Related to Slack thread https://expensify.slack.com/archives/C05LX9D6E07/p1724364263668779
N/A

Tests

@Beamanator can you help me with the test steps here?

  1. Create Collect policy (in OldDot), on Advanced Approvals, and make sure isPolicyExpenseChatEnabled is true
  2. Invite members to the policy, like this:
    1. Submitter[User] -> submitsTo approver A
    2. Approver A[User] -> submitsTo owner
    3. Approver B[User] -> submitsTo owner
  3. As the submitter, create a report with at least one expense report & submit the report
  4. As the owner, change the Submitter's submitsTo to Approver B
  5. As Approver A, make sure you can see the Approve button on the original report from above
  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

  • 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: mWeb Chrome
    • iOS: Native
    • iOS: mWeb 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 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 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 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.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop

@mountiny mountiny self-assigned this Aug 23, 2024
@mountiny mountiny requested a review from a team as a code owner August 23, 2024 14:41
@melvin-bot melvin-bot bot removed the request for review from a team August 23, 2024 14:41
Copy link

melvin-bot bot commented Aug 23, 2024

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

This comment has been minimized.

@Beamanator
Copy link
Contributor

Updated to my understanding of what the text steps should be

@ishpaul777
Copy link
Contributor

ishpaul777 commented Aug 23, 2024

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

Screenshot_2024-08-28-17-33-09-18_1498f0e32f9498230c0f1d86a461cae3.jpg

Android: mWeb Chrome

Screenshot_2024-08-28-17-28-27-41_40deb401b9ffe8e1df2f1cc5ba480b12.jpg

iOS: Native

image

iOS: mWeb Safari

image

MacOS: Chrome / Safari
Screen.Recording.2024-08-28.at.5.12.38.PM.mov
MacOS: Desktop Screenshot 2024-08-28 at 5 41 57 PM

@ishpaul777
Copy link
Contributor

ishpaul777 commented Aug 23, 2024

As Approver A, make sure you can see the Approve button on the original report from above

it seems like once i change approver to userB the report for Approver A becomes unaccessible

RPReplay_Final1724446507.MP4

@ishpaul777
Copy link
Contributor

ishpaul777 commented Aug 23, 2024

And i dont even have approve button for Approver B

Screenshot 2024-08-24 at 2 30 30 AM

cc @mountiny @Beamanator

@mountiny
Copy link
Contributor Author

@ishpaul777 can you check what is the employeeList on the policy and who is the managerID on the report?

@mountiny
Copy link
Contributor Author

Thats definitely odd

@mountiny
Copy link
Contributor Author

@ishpaul777 I dont think these changes will work with pusher updates yet, you might have to sign out and sign back in after each change in the approval chain

@ishpaul777
Copy link
Contributor

@ishpaul777 I dont think these changes will work with pusher updates yet, you might have to sign out and sign back in after each change in the approval chain

still same after sign in and out, if approver is change from user A to B, user A lost access to report and user B dont have "Approve" button

@ishpaul777
Copy link
Contributor

ishpaul777 commented Aug 23, 2024

Screen.Recording.2024-08-24.at.3.31.28.AM-1.mov

Totally accepting if I might be doing a step wrong somewhere 🙏

Basically the user who is approver at the time when the expense is submitted is the only one get approver button but if approver changes A to B, A lost access to report

Subitter -> expense to Approver A
owner change approver to Approver B
Result: A lose access to report, Approver B will not get Approve button

Owner change approver to Approver A again
Result: A got access to report and can approve the expense

@mountiny
Copy link
Contributor Author

So when the report is submitted and awaiting a review from Approver A, that approver should not lose access to the report when the approver is changed.

This is odd, maybe there is something missing in the test steps / policy setup required to replicate the flow we hit with the contributor policy @Beamanator

@ishpaul777
Copy link
Contributor

ishpaul777 commented Aug 26, 2024

FI, i tried changing Approver role to Workspace Admin and then changing approver to other user in this case user dont lose access to report but approver button is also not working in this case

Screen.Recording.2024-08-26.at.6.46.49.PM.mov

@mountiny
Copy link
Contributor Author

@ishpaul777 I am not sure still sorry, this is odd. @Beamanator would you be able to help out @ishpaul777 here as you are much more fluent in this flow, I am trying to focus on workspace feeds right now to close the wave-collect

@mountiny
Copy link
Contributor Author

mountiny commented Aug 27, 2024

@ishpaul777 I feel like your setup is still not exactly what @JmillsExpensify had in his policy.

@JmillsExpensify might be able to help us, @ishpaul777 can you highlight how exactly does your setup look like for the policy/ settings/ approval chain

@JmillsExpensify
Copy link

Jumping in to try and help with the reproduction steps for this case. I think this should do it, as it's minimally how we discovered this issue:

  • Admin A create a Control workspace on OldDot. Workspace is policyExpenseChatEnabled
  • Admin invites User B and User C as members.
  • Amin invites User D and User E. User D is the submitsTo for B. User E is the submitsTo for C
  • Have User B and User C submit reports for approval
  • Confirm that both User D and User E see workspace chats for the relevant members in NewDot, including the ability to approve the report
  • Now in OldDot, have Admin A change the approval workflow. Now User D is the submitsTo for C. User E is the submitsTo for B
  • Confirm that User D and User E have workspace chats for the right members, and that they are able to approve those respective reports.

@ishpaul777
Copy link
Contributor

Thanks @JmillsExpensify I'll try these steps.

@ishpaul777 can you highlight how exactly does your setup look like for the policy/ settings/ approval chain

its same as given in PR test steps:

  • Create Collect policy (in OldDot), on Advanced Approvals, and make sure isPolicyExpenseChatEnabled is true
  • Invite members to the policy, like this:
    • Submitter[User] -> submitsTo approver A
    • Approver A[User] -> submitsTo owner
    • Approver B[User] -> submitsTo owner

@ishpaul777
Copy link
Contributor

Have User B and User C submit reports for approval
Confirm that both User D and User E see workspace chats for the relevant members in NewDot, including the ability to approve the report

@JmillsExpensify is this correct i feel user D and E submits and B and C approve??

@ishpaul777
Copy link
Contributor

Confirm that User D and User E have workspace chats for the right members, and that they are able to approve those respective reports.

@JmillsExpensify This seems true if the expense is submitted after the switch of approvers, but for expense submitted before switch, and it is still unapproved and the new Approver B of E can't see approve button, and Approver C of D can't see approve button is this expected ?

@Beamanator
Copy link
Contributor

Huh from this video: #47926 (comment)

  • I don't reeeeeally understand what's going on - your test user names are so confusing 🤣 and it looks like there's multiple with a name of sa? 😅

Maybe we can pull main, create a new adhoc build, then get @garrettmknight to test this PR tomorrow to see what he gets 🙏

@Beamanator
Copy link
Contributor

Beamanator commented Aug 28, 2024

Ok here's what I'm trying:

  • Admin creates a Collect workspace on NewDot, then updates to Control (it updated to non instant submit)
  • Admin invites Submitter, Approver 1, Approver 2 as members (via NewDot).
  • Admin sets Submitter -> Approver 1 via workflow approvers (in NewDot)
  • Have Submitter submit an expense in the workspace chat & submit
    • Verified it submitted to Approver 1 👍
    • Verified Approver 1 sees workspace chat for Submitter & can access the report & can see Approve button (all in NewDot) 👍
    • Here's what I saw, first time Approver 1 ever logged in, at this point:
    • Screenshot 2024-08-27 at 7 43 06 PM
  • Now in OldDot, have Admin change the approval workflow. Now Approver 2 is the submitsTo for Submitter.
    • Verified Approver 2 sees workspace chat for Submitter 👍 & has access to the expense report 👍 & doesn't see Approve button 👍 & Approver 1 is still manager for expense report 👍
    • Approver 1 SHOULD still have access to the expense report, that is hopefully being fixed in https://github.com/Expensify/Auth/pull/12259
    • Approver 1 SHOULD be able to see the Approve button (the fix from this PR) but that can really only be tested once ^ is fixed
    • Video of this below
Screen.Recording.2024-08-27.at.10.48.10.PM.mov

@mountiny
Copy link
Contributor Author

Copy link
Contributor

🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪

Android 🤖 iOS 🍎
❌ FAILED ❌ https://ad-hoc-expensify-cash.s3.amazonaws.com/ios/47926/index.html
The QR code can't be generated, because the android build failed iOS
Desktop 💻 Web 🕸️
https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/47926/NewExpensify.dmg https://47926.pr-testing.expensify.com
Desktop Web

👀 View the workflow run that generated this build 👀

@garrettmknight
Copy link
Contributor

Tested and confirmed that Approver A has access to the Approve button even when they've been removed from the workflow + workspace chat.

@mountiny
Copy link
Contributor Author

@ishpaul777 Are you able to complete the checklist and approve the PR? Garrett confirmed that this works for our needs now internally so the pr should be good to go. Thanks!

@melvin-bot melvin-bot bot requested a review from cristipaval August 28, 2024 12:04
Copy link

melvin-bot bot commented Aug 28, 2024

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

Copy link

melvin-bot bot commented Aug 28, 2024

🎯 @ishpaul777, thanks for reviewing and testing this PR! 🎉

An E/App issue has been created to issue payment here: #48166.

Copy link
Contributor

@Beamanator Beamanator left a comment

Choose a reason for hiding this comment

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

LGTM

@Beamanator Beamanator merged commit c12adce into main Aug 28, 2024
16 checks passed
@Beamanator Beamanator deleted the vit-removeDependencyOnParentReportForReportApproval branch August 28, 2024 16:11
@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.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/Beamanator in version: 9.0.26-1 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/puneetlath in version: 9.0.26-6 🚀

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants