App icon indicating copy to clipboard operation
App copied to clipboard

Fix - Expense - Submit button appears for archived workspace chat if delayed submission is enabled

Open FitseTLT opened this issue 1 year ago • 23 comments

Details

Fixed Issues

$ https://github.com/Expensify/App/issues/49169 PROPOSAL: https://github.com/Expensify/App/issues/49169#issuecomment-2422644999

Tests

  1. Create a workspace from User A
  2. Invite User B
  3. Submit an expense report from User B's account
  4. Remove User B from the workspace using User A's account
  5. From User B side open the archive workspace chat
  6. Open the expense report you submitted in (3) and verify that composer is visible (not hidden)
  • [x] Verify that no errors appear in the JS console

Offline tests

Same as above

QA Steps

Same as above

  • [x] Verify that no errors appear in the JS console

PR Author Checklist

  • [x] I linked the correct issue in the ### Fixed Issues section above
  • [x] I wrote clear testing steps that cover the changes made in this PR
    • [x] I added steps for local testing in the Tests section
    • [x] I added steps for the expected offline behavior in the Offline steps section
    • [x] I added steps for Staging and/or Production testing in the QA steps section
    • [x] I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • [x] 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)
    • [x] 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).
  • [x] I included screenshots or videos for tests on all platforms
  • [x] I ran the tests on all platforms & verified they passed on:
    • [x] Android: Native
    • [x] Android: mWeb Chrome
    • [x] iOS: Native
    • [x] iOS: mWeb Safari
    • [x] MacOS: Chrome / Safari
    • [x] MacOS: Desktop
  • [x] 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)
  • [x] I followed proper code patterns (see Reviewing the code)
    • [x] 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)
    • [x] I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • [x] I verified that comments were added to code that is not self explanatory
    • [x] 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.
    • [x] I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • [x] 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:
    • [x] I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • [x] 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.
    • [x] 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.
    • [x] I verified the JSDocs style guidelines (in STYLE.md) were followed
  • [x] If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • [x] I followed the guidelines as stated in the Review Guidelines
  • [x] 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)
  • [x] I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • [x] 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
  • [x] I verified that if a function's arguments changed that all usages have also been updated correctly
  • [x] If any new file was added I verified that:
    • [x] 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
  • [x] If a new CSS style is added I verified that:
    • [x] A similar style doesn't already exist
    • [x] The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))
  • [x] 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.
  • [x] 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)
  • [x] 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.
  • [x] 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.
  • [x] If the PR modifies the form input styles:
    • [x] I verified that all the inputs inside a form are aligned with each other.
    • [x] I added Design label so the design team can review the changes.
  • [x] 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.
  • [x] 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

https://github.com/user-attachments/assets/1816f8f7-8fba-46e7-83ec-fa7f4f05586d

Android: mWeb Chrome

https://github.com/user-attachments/assets/164dca31-b23b-4649-bf86-288355bf0775

iOS: Native

https://github.com/user-attachments/assets/b20ca370-cadf-4ee6-987c-9f721f3cd34b

iOS: mWeb Safari

https://github.com/user-attachments/assets/263391bf-b5a0-45f6-a766-0d7212a65e0c

MacOS: Chrome / Safari

https://github.com/user-attachments/assets/d813db7c-1f18-4fee-b6db-ee8cbe64f987

MacOS: Desktop

https://github.com/user-attachments/assets/873c6c03-ea62-4802-b7f5-1800229efe0a

FitseTLT avatar Nov 07 '24 13:11 FitseTLT

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

melvin-bot[bot] avatar Nov 07 '24 13:11 melvin-bot[bot]

@FitseTLT what's the ETA for this PR? It's holding up a couple other PRs so just wanted to check. Also, we should try to be a little careful with this since it has a chance to cause regressions. By this, I mean that we should check all occurrences of isArchivedRoom and isArchivedRoomWithID to make sure that any that deal with expense reports are switched over to isArchivedExpenseReport. Otherwise, archived expense reports will be able to be Paid, Submitted or Approved which we don't want.

srikarparsi avatar Nov 13 '24 00:11 srikarparsi

@FitseTLT what's the ETA for this PR? It's holding up a couple other PRs so just wanted to check. Also, we should try to be a little careful with this since it has a chance to cause regressions. By this, I mean that we should check all occurrences of isArchivedRoom and isArchivedRoomWithID to make sure that any that deal with expense reports are switched over to isArchivedExpenseReport. Otherwise, archived expense reports will be able to be Paid, Submitted or Approved which we don't want.

I am working on it. Will provide update tomorrow 👍

FitseTLT avatar Nov 13 '24 21:11 FitseTLT

I have checked all instances of isArchivedRoom and isArchivedRoomWithID and I have listed down some case I want confirmation from U

  1. I believe we don't want to hide edit, flag as offensive, delete action, join thread menu items for archive expense report.
  2. https://github.com/Expensify/App/blob/58258ed4d00588888c00296778bd919dc6d3a4a1/src/components/MoneyReportHeader.tsx#L253-L258 https://github.com/Expensify/App/blob/58258ed4d00588888c00296778bd919dc6d3a4a1/src/components/ReportActionItem/ReportPreview.tsx#L369-L372 which I think you were discussing about above and you should help me what to do with them.
  3. canAddTransaction, canDeleteTransaction, ??
  4. getReasonAndReportActionThatRequiresAttention we return null if it is archived room or the parent report is. Should it require attention?
  5. getPolicyExpenseChatName , getReportName whether to show archived suffix
  6. reasonForReportToBeInOptionList: Archived reports should always be shown when in default (most recent) mode
  7. shouldShowFlagComment - we don't show flag comment page for archived pages should we
  8. shouldReportShowSubscript - we don't show subtitle for archived reports, what about our for expense reports
  9. canUserPerformWriteAction - I think we want to allow write action in order to allow commenting
  10. shouldDisableThread - we want to enable reply in thread (let me know if you disagree
  11. getOrderedReportIDs - we order the archived reports last in LHN
  12. BaseReportActionContextMenu - whether to show hold and unhold menu in context menu
  13. ReportActionItem - I don't think we want to disable emoji picker button in ReportActionItemMessageEdit
  14. In report details page - we are currently showing cancel payment, unapproved, delete expense and oddly it works the BE correctly handles them. WDYT we should leave it ??

Now to confirm: You are aiming to set is_privateArchived for expense reports from BE. Correct me if I am wrong.

Last question: I know we want to allow commenting and so on on open archive expense reports but what about settled archived reports we want the same behaviour as the unsettled one? This might also decide our isArchivedExpenseReport.

FitseTLT avatar Nov 14 '24 21:11 FitseTLT

Thank you for all the questions @FitseTLT, I'll get to them tomorrow since I need to look at some of the backend code

srikarparsi avatar Nov 15 '24 08:11 srikarparsi

I believe we don't want to hide edit, flag as offensive, delete action, join thread menu items for archive expense report.

Yes, since they are still able to be commented on, we don't want to hide these menu items

What to do with ARCHIVE_REASON.BOOKING_END_DATE_HAS_PASSED

We do want to show this as archived. So the isArchivedReport should query for the last action and if it is this, then even if it's an expense report, then it should still be considered as archived.

canAddTransaction, canDeleteTransaction, ??

This should not be possible with isArchivedReport or isArchivedExpenseReport

getReasonAndReportActionThatRequiresAttention we return null if it is archived room or the parent report is. Should it require attention?

I think no right now because there is nothing actionable on these expense reports so they shouldn't have RBRs or GBRs. (The move button doesn't exist yet). But @trjExpensify could you help confirm?

getPolicyExpenseChatName , getReportName whether to show archived suffix

No, we should not show the archived suffix for expense reports

reasonForReportToBeInOptionList: Archived reports should always be shown when in default (most recent) mode

Yes, but for the expense reports, the reason should not be archived but rather the regular expense report reasons.

shouldShowFlagComment - we don't show flag comment page for archived pages should we

Yes, we should show it for expense reports because they are still able to be commented on

shouldReportShowSubscript - we don't show subtitle for archived reports, what about our for expense reports

Yes, we should show subscript, expense reports shouldn't be visibly archived in the frontend.

canUserPerformWriteAction - I think we want to allow write action in order to allow commenting

Yes.

shouldDisableThread - we want to enable reply in thread (let me know if you disagree

Yes, we want to enable reply in thread

getOrderedReportIDs - we order the archived reports last in LHN

Expense reports shouldn't be considered archived so we don't want to order these last

BaseReportActionContextMenu - whether to show hold and unhold menu in context menu

I don't believe we want to show hold and unhold either for archived expense reports. @trjExpensify do you think you can confirm this one as well.

ReportActionItem - I don't think we want to disable emoji picker button in ReportActionItemMessageEdit

Yes, we do not for archived expense reports.

In report details page - we are currently showing cancel payment, unapproved, delete expense and oddly it works the BE correctly handles them. WDYT we should leave it ??

I don't think we want to show any action buttons on archived expense reports. @trjExpensify can you please help confirm this one as well?

You are aiming to set is_privateArchived for expense reports from BE. Correct me if I am wrong.

Yes, but after we merge this PR so that users are able to continue commenting on expense reports. If we do that first before merging this PR, users won't be able to comment on expense reports until this PR gets deployed.

I know we want to allow commenting and so on on open archive expense reports but what about settled archived reports we want the same behaviour as the unsettled one?

Yes, I believe we want the same behavior for all expense reports. I had the same question here and @trjExpensify recommended we should retain the ability to chat on all archived expense reports.

Please let me know if you have any other questions.

srikarparsi avatar Nov 19 '24 09:11 srikarparsi

@srikarparsi Applied all changes. Only doubt here https://github.com/Expensify/App/blob/e9e18573960d492a29b2563237024f0dc3c37f85/src/components/ReportActionItem/ReportPreview.tsx#L364 https://github.com/Expensify/App/blob/e9e18573960d492a29b2563237024f0dc3c37f85/src/components/MoneyReportHeader.tsx#L121 We use the variable to determine the status bar prop. I know I asked you last time but it is not clear to me can you tell me directly what function to use, is it isArchivedNonExpenseReport or isArchivedAnyReport ?

FitseTLT avatar Nov 21 '24 22:11 FitseTLT

Sorry, I weirdly didn't catch this in my inbox until that latest comment.

I think no right now because there is nothing actionable on these expense reports so they shouldn't have RBRs or GBRs. (The move button doesn't exist yet). But @trjExpensify could you help confirm?

Agreed, no RBR/GBR. We should add the ability to change the workspace the expense report is on soon though!

BaseReportActionContextMenu - whether to show hold and unhold menu in context menu

I don't believe we want to show hold and unhold either for archived expense reports. @trjExpensify do you think you can confirm this one as well.

Hmm, I don't see a reason to restrict these.

In report details page - we are currently showing cancel payment, unapproved, delete expense and oddly it works the BE correctly handles them. WDYT we should leave it ??

I don't think we want to show any action buttons on archived expense reports. @trjExpensify can you please help confirm this one as well?

Same here, I think we should leave these as they are. OldDot doesn't restrict actions like reject, unapprove, delete etc when the workspace is deleted. Only Submit > Approve > Pay.

Yes, I believe we want the same behavior for all expense reports. I had the same question https://github.com/Expensify/App/issues/49169#issuecomment-2362952016 and @trjExpensify recommended we should retain the ability to chat on all archived expense reports.

Agreed.

trjExpensify avatar Nov 21 '24 22:11 trjExpensify

@srikarparsi I will need a confirmation on two of @trjExpensify responses and will make the changes as soon as you guys agree on it but the other responses are already aligned to the current code 👍 BaseReportActionContextMenu - whether to show hold and unhold menu in context menu

I don't believe we want to show hold and unhold either for archived expense reports. @trjExpensify do you think you can confirm this one as well.

Hmm, I don't see a reason to restrict these.

In report details page - we are currently showing cancel payment, unapproved, delete expense and oddly it works the BE correctly handles them. WDYT we should leave it ??

I don't think we want to show any action buttons on archived expense reports. @trjExpensify can you please help confirm this one as well?

Same here, I think we should leave these as they are. OldDot doesn't restrict actions like reject, unapprove, delete etc when the workspace is deleted. Only Submit > Approve > Pay.

FitseTLT avatar Nov 22 '24 13:11 FitseTLT

Thanks @trjExpensify and @FitseTLT. Let's move forward with what @trjExpensify said in this comment, I also agree with it.

srikarparsi avatar Nov 22 '24 23:11 srikarparsi

@srikarparsi Applied all changes. What should I do in terms of test steps or screenshots? I can't test it before the BE changes are made. What's the plan for the next step?

FitseTLT avatar Nov 25 '24 13:11 FitseTLT

Thanks @FitseTLT. When an workspace is deleted, the expense reports on it won't have the private_isArchived rNVP, but they will after the backend changes.

For now, you can emulate expense reports having the private_isArchived by removing a member from a workspace:

  1. Create a workspace from User A
  2. Invite User B
  3. Submit an expense report from User B's account
  4. Pay the expense report elsewhere from User A's account
  5. Remove User B from the workspace using User A's account
  6. Click into the expense report (It should have the private_isArchived rNVP)

You can use this for screenshots and testing. Also @Ollyws if you can take a look at this whenever you have a chance that would be great since this is holding up some other development so would love to get this out tomorrow or Wednesday :)

Also, if we could make sure that this won't cause any regressions to current archived behavior with chats and tasks that would be great!

srikarparsi avatar Nov 26 '24 07:11 srikarparsi

@srikarparsi With the archiving that is caused by being removed from the workspace like you suggested above, the BE returns error (This chat room is archived) when comment in the expense rreport. What's you plan on this, I think we need a BE change? Because we are allowing commenting in this PR and this would be a regression.

FitseTLT avatar Nov 26 '24 22:11 FitseTLT

Thanks for bringing this up. I created a backend PR to allow commenting on archived expense reports. But please continue testing etc. apart from that bug so that once the internal PR goes to production we can merge this.

srikarparsi avatar Nov 27 '24 08:11 srikarparsi

@srikarparsi

  1. what about expense requests? we only allowed for archived expense reports but if we have multiple expense requests inside an expense report we are still not allowing commenting for the expense requests do you think we should apply the change to expense requests too like
function isArchivedNonExpenseReport(report: OnyxInputOrEntry<Report> | SearchReport, reportNameValuePairs?: OnyxInputOrEntry<ReportNameValuePairs>): boolean {
    return !(isExpenseReport(report) || isExpenseRequest(report)) && !!report?.private_isArchived;
}
  1. Do we allow editing of the expense fields like date ...? I think no, right?

FitseTLT avatar Nov 27 '24 15:11 FitseTLT

  1. Do we allow editing of the expense fields like date ...? I think no, right?

Outside of the normal report state/access restrictions, yes.

trjExpensify avatar Nov 27 '24 16:11 trjExpensify

do you think we should apply the change to expense requests

Yes, expenses on an expense report shouldn't be archived 👍

trjExpensify avatar Nov 27 '24 16:11 trjExpensify

@trjExpensify Do we remove settings, members and leave menu items in report details page? I think we need export and download menu for archived expense reports but let me know your opinion.

FitseTLT avatar Nov 27 '24 20:11 FitseTLT

@trjExpensify Do we remove settings, members and leave menu items in report details page?

Why would we remove any of those?

trjExpensify avatar Nov 28 '24 00:11 trjExpensify

Hey @FitseTLT and @Ollyws! Is there any update on this PR?

srikarparsi avatar Dec 04 '24 10:12 srikarparsi

@srikarparsi I have re-reviewed the whole code and made necessary changes twice and also tested it so only left with making more tests and record snapshots after the BE changes are ready 👍

FitseTLT avatar Dec 04 '24 13:12 FitseTLT

Hi @FitseTLT, the BE changes should be on production. Could you take a look whenever you get a chance?

srikarparsi avatar Dec 06 '24 11:12 srikarparsi

Hi @FitseTLT, the BE changes should be on production. Could you take a look whenever you get a chance?

on it

FitseTLT avatar Dec 06 '24 12:12 FitseTLT

@srikarparsi

  1. You have forgotten to make same BE changes you made for expense reports to expense requests too so if you have two requests in an expense report, you can comment on the expense report but not in the expense request reports
  2. The link to the parent archive workspace chat will show as archived like below, do you want archived removed? I mean it might be correct to leave it b/c it is only indicating that the parent workspace chat is archived, WDYT. Screenshot 2024-12-09 at 7 09 22 in the evening
  3. Although I allowed hold in FE based on your suggestions, the BE returns error

I have made one last review of the code and testing, I am only left with rec screen shots. Let me know your opinion on the above comments and will proceed 👍

FitseTLT avatar Dec 09 '24 17:12 FitseTLT

You have forgotten to make same BE changes you made for expense reports to expense requests too so if you have two requests in an expense report, you can comment on the expense report but not in the expense request reports

Yes, this is a work in progress. Have a PR for it here which should get merged in the next couple days.

The link to the parent archive workspace chat will show as archived like below, do you want archived removed? I mean it might be correct to leave it b/c it is only indicating that the parent workspace chat is archived, WDYT.

Yes, that is fine because as you said it indicates that the parent workspace chat is archived

Although I allowed hold in FE based on your suggestions, the BE returns error

I'll take a look at this but please continue testing/screenshots @FitseTLT and @Ollyws. Once 1 and 3 are fixed, we can merge.

srikarparsi avatar Dec 10 '24 07:12 srikarparsi

Hey @FitseTLT, how is this one looking? Do you think this can be ready for review today?

srikarparsi avatar Jan 05 '25 19:01 srikarparsi

Ready for review 👍 @srikarparsi @Ollyws

FitseTLT avatar Jan 06 '25 17:01 FitseTLT

Great, will review asap.

Ollyws avatar Jan 06 '25 18:01 Ollyws

This important to avoid crash when the report id changes from empty string to other value.

On Tue, 7 Jan 2025 at 12:24 AM Olly @.***> wrote:

@.**** commented on this pull request.

In src/pages/home/report/ReportActionItem.tsx https://github.com/Expensify/App/pull/52183#discussion_r1904652215:

@@ -32,12 +32,12 @@ function ReportActionItem({action, report, ...props}: PureReportActionItemProps) {selector: (transaction) => transaction?.errorFields?.route ?? null}, ); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- This is needed to prevent the app from crashing when the app is using imported state.

  • const [reportNameValuePairs] = useOnyx(${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID});
  • const [reportNameValuePairs] = useOnyx(${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID || undefined});

Is this necessary? reportID would be undefined already no?

— Reply to this email directly, view it on GitHub https://github.com/Expensify/App/pull/52183#pullrequestreview-2532997522, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJG4AZPCUYK45MDINLKM4DT2JLYBFAVCNFSM6AAAAABRLG73KCVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDKMZSHE4TONJSGI . You are receiving this because you were mentioned.Message ID: @.***>

FitseTLT avatar Jan 06 '25 21:01 FitseTLT

If we delete the workspace (without first removing the user) Create expense still exists and the backend throws an error if you create one. This also happens on staging:

Screenshot 2025-01-07 at 14 38 41

Ollyws avatar Jan 07 '25 13:01 Ollyws