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

[Free trial] Restrict actions throughout the App of "past due" billing owner #44393

Merged

Conversation

fabioh8010
Copy link
Contributor

@fabioh8010 fabioh8010 commented Jun 25, 2024

Details

This PR implements the restrict actions logic for the user, admin and owner against a "past due" billing workspace. (Design doc)

Fixed Issues

$ #43674
PROPOSAL:

Tests

Workspace User

Prerequisites

  1. The user must be a member of the workspace you created with another account.
  2. The workspace must have the Approvals workflow enabled.
  3. Add the following code to Expensify.tsx in order to set the Onyx keys during initialisation, where <ownerAccountID> is the account ID of the workspace's owner, and <timestamp> is your current date in Unix timestamp minus some days to simulate that the owner is past due billing (Use https://www.unixtimestamp.com/ to calculate it).
    useEffect(() => {
        Onyx.multiSet({
            [`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END}<ownerAccountID>` as const]: {
                name: '',
                permissions: '',
                value: <timestamp>,
            },
            [ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END]: null,
            [ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED]: null,
        });
    }, []);

Test steps

Submitting an expense on a Workspace

  1. Click the FAB button > Submit expense.
  2. Choose manual, any amount, and select the workspace.
  3. Assert the Restricted Action screen was open, and the "Chat with your admin" button will redirect you to the Workspace chat.
  4. Go to the Workspace chat, click the composer "+" button > Submit expense.
  5. Assert the Restricted Action screen was open, and the "Chat with your admin" button will redirect you to the Workspace chat.

Tracking an expense on a Workspace

  1. Go to the Workspace chat, click the composer "+" button > Track expense.
  2. Assert the Restricted Action screen was open, and the "Chat with your admin" button will redirect you to the Workspace chat.

Splitting an expense on a Workspace

  1. Click the FAB button > Split expense.
  2. Choose manual, any amount, and select the workspace.
  3. Assert the Restricted Action screen was open, and the "Chat with your admin" button will redirect you to the Workspace chat.
  4. Go to the Workspace chat, click the composer "+" button > Split expense.
  5. Assert the Restricted Action screen was open, and the "Chat with your admin" button will redirect you to the Workspace chat.

Use the following code to reset Onyx data.

useEffect(() => {
    Onyx.multiSet({
        [`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END}<ownerAccountID>` as const]: null,
        [ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END]: null,
        [ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED]: null,
    });
}, []);

Workspace Admin

Prerequisites

Same as Workspace User prerequisites, except that now the user must be a admin of the workspace you created with another account.

Test steps

Submitting an expense on a Workspace

  1. Click the FAB button > Submit expense.
  2. Choose manual, any amount, and select the workspace.
  3. Assert the Restricted Action screen was open, and the "Chat in #admins" button will redirect you to the #admins chat.
  4. Go to the Workspace chat, click the composer "+" button > Submit expense.
  5. Assert the Restricted Action screen was open, and the "Chat in #admins" button will redirect you to the #admins chat.

Tracking an expense on a Workspace

  1. Go to the Workspace chat, click the composer "+" button > Track expense.
  2. Assert the Restricted Action screen was open, and the "Chat in #admins" button will redirect you to the #admins chat.

Splitting an expense on a Workspace

  1. Click the FAB button > Split expense.
  2. Choose manual, any amount, and select the workspace.
  3. Assert the Restricted Action screen was open, and the "Chat in #admins" button will redirect you to the #admins chat.
  4. Go to the Workspace chat, click the composer "+" button > Split expense.
  5. Assert the Restricted Action screen was open, and the "Chat in #admins" button will redirect you to the #admins chat.

Use the following code to reset Onyx data.

useEffect(() => {
    Onyx.multiSet({
        [`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END}<ownerAccountID>` as const]: null,
        [ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END]: null,
        [ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED]: null,
    });
}, []);

Workspace Owner

Prerequisites

  1. The user must be the owner of the workspace.
  2. The workspace must have the Approvals workflow enabled.
  3. The workspace must be configured to submit expenses manually (Go to https://www.expensify.com/ with the account -> Settings -> Workspaces -> Your Workspace -> Reports -> How often expenses submit, change it to Manually).
  4. Using the same user, go to the Workspace chat, submit an expense but don't click "Submit".
  5. Using the same user, go to the Workspace chat again, submit an expense, click "Submit" and approve it.
  6. Using the same user, go to the Workspace chat again and submit an expense without approving.
  7. Add the following code to Expensify.tsx in order to set the Onyx keys during initialisation, where <timestamp> is your current date in Unix timestamp minus some days to simulate that the owner is past due billing (Use https://www.unixtimestamp.com/ to calculate it).
    useEffect(() => {
        Onyx.multiSet({
            [ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END]: <timestamp>,
            [ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED]: 1000,
        });
    }, []);

Test steps

Submitting an expense on a Workspace

  1. Refresh the App to ensure the Onyx data is applied.
  2. Click the FAB button > Submit expense.
  3. Choose manual, any amount, and select your workspace.
  4. Assert the Restricted Action screen was open, and the "Add payment card button" button will redirect you to the Subscription screen.
  5. Refresh the App to ensure the Onyx data is applied.
  6. Go to your Workspace chat, click the composer "+" button > Submit expense.
  7. Assert the Restricted Action screen was open, and the "Add payment card button" button will redirect you to the Subscription screen.
  8. Go to the Workspace chat again, look for the expense that has the "Submit" button and click it.
  9. Assert the Restricted Action screen was open, and the "Add payment card button" button will redirect you to the Subscription screen.

Tracking an expense on a Workspace

  1. Refresh the App to ensure the Onyx data is applied.
  2. Go to your Workspace chat, click the composer "+" button > Track expense.
  3. Assert the Restricted Action screen was open, and the "Add payment card button" button will redirect you to the Subscription screen.

Approving an expense on a Workspace

  1. Refresh the App to ensure the Onyx data is applied.
  2. Go to your Workspace chat, look for the expense you created before that is pending approval, approve it.
  3. Assert the Restricted Action screen was open, and the "Add payment card button" button will redirect you to the Subscription screen.

Paying an expense on a Workspace

  1. Refresh the App to ensure the Onyx data is applied.
  2. Go to your Workspace chat, look for the expense you created before that is pending payment, pay it.
  3. Assert the Restricted Action screen was open, and the "Add payment card button" button will redirect you to the Subscription screen.

Splitting an expense on a Workspace

  1. Refresh the App to ensure the Onyx data is applied.
  2. Click the FAB button > Split expense.
  3. Choose manual, any amount, and select your workspace.
  4. Assert the Restricted Action screen was open, and the "Add payment card button" button will redirect you to the Subscription screen.
  5. Refresh the App to ensure the Onyx data is applied.
  6. Go to your Workspace chat, click the composer "+" button > Split expense.
  7. Assert the Restricted Action screen was open, and the "Add payment card button" button will redirect you to the Subscription screen.

Use the following code to reset Onyx data.

useEffect(() => {
    Onyx.multiSet({
        [`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END}<ownerAccountID>` as const]: null,
        [ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END]: null,
        [ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED]: null,
    });
}, []);
  • Verify that no errors appear in the JS console

Offline tests

Same as above.

QA Steps

Same as above.

  • 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
Screen.Recording.2024-06-26.at.19.08.24-compressed.mov
iOS: Native
Screen.Recording.2024-06-26.at.19.37.24-compressed.mov
iOS: mWeb Safari
Screen.Recording.2024-06-26.at.19.44.39-compressed.mov
MacOS: Chrome / Safari
Screen.Recording.2024-06-26.at.19.48.14-compressed.mov
Screen.Recording.2024-06-26.at.19.51.31-compressed.mov
MacOS: Desktop
Screen.Recording.2024-06-26.at.20.51.13-compressed.mov

@fabioh8010 fabioh8010 changed the title [WIP] [Free trial] Restrict actions throughout the App of "past due" billing owner [Free trial] Restrict actions throughout the App of "past due" billing owner Jun 26, 2024
@fabioh8010 fabioh8010 marked this pull request as ready for review June 26, 2024 20:11
@fabioh8010 fabioh8010 requested a review from a team as a code owner June 26, 2024 20:11
@melvin-bot melvin-bot bot requested review from rojiphil and removed request for a team June 26, 2024 20:11
Copy link

melvin-bot bot commented Jun 26, 2024

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

@chiragsalian chiragsalian self-requested a review June 26, 2024 20:56
@rojiphil
Copy link
Contributor

@fabioh8010 There are merge conflicts here to be resolved. I will continue to review though.

@fabioh8010
Copy link
Contributor Author

@rojiphil Conflicts resolved

Copy link
Contributor

@rojiphil rojiphil left a comment

Choose a reason for hiding this comment

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

@fabioh8010 Thanks for the PR. Code looks good and tests well too.
But I also have left few comments. Please have a look.

@@ -39,7 +38,7 @@ function WorkspaceUserRestrictedAction({policyID}: WorkspaceUserRestrictedAction
>
<HeaderWithBackButton
title={translate('workspace.restrictedAction.restricted')}
onBackButtonPress={Navigation.goBack}
onBackButtonPress={Navigation.resetToHome}
Copy link
Contributor

@rojiphil rojiphil Jun 27, 2024

Choose a reason for hiding this comment

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

On returning from the Restricted Actions view for users, why do we need to reset the navigation history? Seems too harsh on the user for no fault of his.

Personally, I would not recommend to reset the navigation history even for Admins and Owner. Also, we reset the navigation history when we guide the user/admin/owner to the appropriate report.

Also, for the scenario of manual/split request, I think the user would expect to go back to the participant selection page instead of abruptly ending the request. no?

Is this all intentional/agreed upon somewhere? Maybe I am missing something here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I keep the previous behavior this is what happens on mobile for example:

Screen.Recording.2024-06-28.at.14.22.20-compressed.mov

FAB -> Submit expense -> Restricted Action -> Workspace chat

If I go back on the workspace chat I will return to the restricted action, which i don't think it makes much sense. I'm not familiar with the navigation system so that's why I'm resetting like this, do you have any thoughts about the flow with goBack vs resetToHome?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the comment here may solve this problem.

@rojiphil
Copy link
Contributor

rojiphil commented Jun 27, 2024

@chiragsalian I notice that we do not restrict submit action for users whereas we restrict approve and pay. And I also do not find any reference to this in the design document.
Is this intentionally omitted or did we miss this?

44393-submit-issue.mp4

@rojiphil
Copy link
Contributor

rojiphil commented Jun 27, 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

MacOS: Chrome / Safari
44393-web-safari-all-002.mp4
MacOS: Desktop
44393-desktop-admin-001.mp4
Android: Native
44393-android-native-admin-001.mp4
44393-android-native-owner-001.mp4
44393-android-native-user-001.mp4
Android: mWeb Chrome
44390-mweb-chrome-001.mp4
iOS: Native
44393-ios-native-admin-002.mp4
44393-ios-native-owner-001.mp4
iOS: mWeb Safari
44393-mweb-safari-user-001.mp4

@chiragsalian
Copy link
Contributor

@chiragsalian I notice that we do not restrict submit action for users whereas we restrict approve and pay. And I also do not find any reference to this in the design document.

From the design doc, these are the actions that we'll have to restrict,

  1. Submitting a request on a workspace.
  2. Tracking an expense on a workspace.
  3. Approving a request on a workspace.
  4. Paying a request on a workspace.
  5. Splitting an expense on a workspace.

But i see fabio included these in his test steps. I see he tests for submitting a request. Did you test the same steps and they did not work for you or did you mean something else? I'm wondering if there was some edge case you might have noticed. In your video was that the workspace owner or admin?

@rojiphil
Copy link
Contributor

But i see fabio included these in his test steps. I see he tests for submitting a request. Did you test the same steps and they did not work for you or did you mean something else? I'm wondering if there was some edge case you might have noticed. In your video was that the workspace owner or admin?

@chiragsalian Hmm... Looks like we use the same term to describe two actions which is causing confusion. We use the same term while, a) Initiating a Submit Expense via FAB/Workspace menu and, b) Submitting an expense via Report Action button for further processing. Anyway, I am referring to the functionality of submitting an expense via report action as shown below. This is applicable for all users i.e. employee,admin,owner. Since we do not have any reference to this in the design document, I just wanted to reconfirm if this was intentionally left out.

Screenshot 2024-06-28 at 10 34 09 AM

@rojiphil
Copy link
Contributor

@fabioh8010 I was unable to test the workspace chat scenarios for workspace owner as the workspace chat itself do not show up. But I do get the workspace chat for admin though. What am I missing here?

@fabioh8010
Copy link
Contributor Author

@chiragsalian Hmm... Looks like we use the same term to describe two actions which is causing confusion. We use the same term while, a) Initiating a Submit Expense via FAB/Workspace menu and, b) Submitting an expense via Report Action button for further processing. Anyway, I am referring to the functionality of submitting an expense via report action as shown below. This is applicable for all users i.e. employee,admin,owner. Since we do not have any reference to this in the design document, I just wanted to reconfirm if this was intentionally left out.

I will wait on this discussion as I don't really know if this case should be covered by the restriction.


@fabioh8010 I was unable to test the workspace chat scenarios for workspace owner as the workspace chat itself do not show up. But I do get the workspace chat for admin though. What am I missing here?

@rojiphil I'm not sure if I understood, could you elaborate more? Did you try my test steps?

@chiragsalian
Copy link
Contributor

@chiragsalian Hmm... Looks like we use the same term to describe two actions which is causing confusion. We use the same term while, a) Initiating a Submit Expense via FAB/Workspace menu and, b) Submitting an expense via Report Action button for further processing. Anyway, I am referring to the functionality of submitting an expense via report action as shown below. This is applicable for all users i.e. employee,admin,owner. Since we do not have any reference to this in the design document, I just wanted to reconfirm if this was intentionally left out.

I will wait on this discussion as I don't really know if this case should be covered by the restriction.

Yeah i think we should add a restriction for submitting an expense via a report action as well. Basically submitting an expense anywhere should be restricted. @MitchExpensify can you double check and confirm as well.

@@ -28,7 +27,7 @@ function WorkspaceUserRestrictedAction({policyID}: WorkspaceUserRestrictedAction

const openPolicyExpenseReport = useCallback(() => {
const reportID = ReportUtils.findPolicyExpenseChatByPolicyID(policyID)?.reportID ?? '-1';
Report.openReport(reportID);
// Navigation.resetToHome();
Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. I think the following may solve our problem. Can you also please test this out?

Suggested change
// Navigation.resetToHome();
Navigation.closeRHPFlow();
44393-back-issue.mp4

@trjExpensify
Copy link
Contributor

Yeah i think we should add a restriction for submitting an expense via a report action as well. Basically submitting an expense anywhere should be restricted. @MitchExpensify can you double check and confirm as well.

Yes, they should be restricted from submitting an expense report everywhere, so via a report action as well. 👍

@fabioh8010
Copy link
Contributor Author

@rojiphil Addressed the comments about the navigation and tested, looks better I think, please have a look!

@rojiphil @chiragsalian @MitchExpensify @trjExpensify Also addressed the submit action and now we are restricting it too.

@rojiphil

This comment was marked as outdated.

Copy link
Contributor

@rojiphil rojiphil left a comment

Choose a reason for hiding this comment

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

@fabioh8010 Thanks for the changes. Code looks good and tests well too. We are almost there for PR approval. And the checklist is also almost done.

  1. Pending work is to resolve the merge conflicts. Once resolved, will verify the outcome again.
  2. Please add the test steps for submitting expense via report action.

@rojiphil
Copy link
Contributor

rojiphil commented Jul 1, 2024

@fabioh8010 I was unable to test the workspace chat scenarios for workspace owner as the workspace chat itself do not show up. But I do get the workspace chat for admin though. What am I missing here?

@rojiphil I'm not sure if I understood, could you elaborate more? Did you try my test steps?

Specific to your test videos, I am referring to the workspace equivalent to My Past Due Workspace for workspace owner. What am I missing to get such a workspace?

And specific to the test steps, I am unable to test scenarios on a workspace i.e. Submitting/Tracking/Splitting an expense on a workspace for Workspace Owner

Screenshot 2024-07-02 at 12 19 04 AM

@fabioh8010
Copy link
Contributor Author

@rojiphil I resolved the conflicts and updated test steps, please have another look.

Regarding the Workspace Owner tests, please follow the instructions I put and try using this code instead.

useEffect(() => {
    Onyx.multiSet({
        [ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END]: 1719818912,
        [ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED]: 1000,
    });
}, []);

Also, please note that we've renamed NVP_PRIVATE_AMOUNT_OWNED to NVP_PRIVATE_AMOUNT_OWED, it was wrong before.

Copy link
Contributor

@rojiphil rojiphil left a comment

Choose a reason for hiding this comment

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

Thanks @fabioh8010 . Tests well and completed checklist.
I still could not get the workspace chat for workspace owner though. But I think that’s fine since I have tested the workspace chat for workspace admin.
@chiragsalian. All yours.

Copy link
Contributor

@chiragsalian chiragsalian left a comment

Choose a reason for hiding this comment

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

Code LGTM.

@chiragsalian chiragsalian merged commit 22bcc98 into Expensify:main Jul 2, 2024
15 checks passed
@OSBotify
Copy link
Contributor

OSBotify commented Jul 2, 2024

✋ 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

OSBotify commented Jul 3, 2024

🚀 Deployed to staging by https://github.com/chiragsalian in version: 9.0.4-0 🚀

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

@OSBotify
Copy link
Contributor

OSBotify commented Jul 4, 2024

🚀 Cherry-picked to staging by https://github.com/tgolen in version: 9.0.4-5 🚀

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

@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes.

@kavimuru
Copy link

kavimuru commented Jul 5, 2024

@fabioh8010 Where do we run the scripts and how to run this step

Add the following code to Expensify.tsx in order to set the Onyx keys during initialisation, where is your current date in Unix timestamp minus some days to simulate that the owner is past due billing (Use https://www.unixtimestamp.com/ to calculate it).

@fabioh8010
Copy link
Contributor Author

@kavimuru You must add the useEffect() code right after the last useEffect() you can find in src/Expensify.tsx. For example:

function Expensify({
    isCheckingPublicRoom = true,
    session,
    updateAvailable,
    isSidebarLoaded = false,
    screenShareRequest,
    updateRequired = false,
    focusModeNotification = false,
    lastVisitedPath,
}: ExpensifyProps) {
    ...
    // This is being done since we want to play sound even when iOS device is on silent mode, to align with other platforms.
    useEffect(() => {
        Audio.setAudioModeAsync({playsInSilentModeIOS: true});
    }, []);

    // Add the useEffect() here. <----------------------------------------

    // Display a blank page until the onyx migration completes
    if (!isOnyxMigrated) {
        return null;
    }

    if (updateRequired) {
        throw new Error(CONST.ERROR.UPDATE_REQUIRED);
    }

    return (
    ...
}

@kavimuru
Copy link

kavimuru commented Jul 5, 2024

@trjExpensify @MitchExpensify @fabioh8010 Do we run these scripts in the console? Could you help us?

@rojiphil

This comment was marked as off-topic.

@rojiphil
Copy link
Contributor

rojiphil commented Jul 5, 2024

Do we run these scripts in the console? Could you help us?

No. These changes are in the code.

@fabioh8010 We have to provide Onyx updates for the QA to test this via Inspect Console.

@chiragsalian
Copy link
Contributor

Oops yeah i missed this in test steps.
@kavimuru, for the Prerequisites step you should run,

  1. First get ownerAccountID. You can get this by logging into the policy owner, and then in chrome debugging tools go to application -> Storage -> Indexed DB -> Onyx db -> keyvaluepairs to see onyx data. Search for userMetaData -> accountID.
  2. Then in console run,
Onyx.merge("sharedNVP_private_billingGracePeriodEnd_<ownerAccountID>", {"name": "private_billingGracePeriodEnd", "permissions": "read", "value": <yesterdays epoch timestamp>});
Onyx.merge("nvp_private_billingGracePeriodEnd", null);
Onyx.merge("nvp_private_amountOwed", null);

To reset Onyx data,

Onyx.merge("sharedNVP_private_billingGracePeriodEnd_<ownerAccountID>", null);
Onyx.merge("nvp_private_billingGracePeriodEnd", null);
Onyx.merge("nvp_private_amountOwed", null);

Workspace Owner, prerequisites,

Onyx.merge("nvp_private_billingGracePeriodEnd", <yesterdays epoch timestamp>);
Onyx.merge("nvp_private_amountOwed", 1000);

@kavimuru
Copy link

kavimuru commented Jul 5, 2024

@chiragsalian QA team is finding difficulty validating this PR. It would be great if this PR could be validated internally. Thanks!

@chiragsalian
Copy link
Contributor

Sure, @fabioh8010 or @rojiphil would you guys be able to test this on staging? If not let me know and I'll test it out.

@rojiphil
Copy link
Contributor

rojiphil commented Jul 6, 2024

Sure, @fabioh8010 or @rojiphil would you guys be able to test this on staging? If not let me know and I'll test it out.

Works well on staging.

44393-web-safari-staging-01.mp4
44393-mweb-chrome-staging-01.mp4

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/Julesssss in version: 9.0.5-13 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/thienlnam in version: 9.0.6-8 🚀

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