Skip to content

Improve conditions for allowing/disallowing editing a money request#29101

Merged
mountiny merged 25 commits into
Expensify:mainfrom
rezkiy37:fix/28963-edit-category-paid-request
Oct 23, 2023
Merged

Improve conditions for allowing/disallowing editing a money request#29101
mountiny merged 25 commits into
Expensify:mainfrom
rezkiy37:fix/28963-edit-category-paid-request

Conversation

@rezkiy37

@rezkiy37 rezkiy37 commented Oct 9, 2023

Copy link
Copy Markdown
Contributor

Details

The PR improves conditions for allowing/disallowing editing a money request based on different values of a current user and current money request.

Fixed Issues

$ #28963
PROPOSAL: N/A

Tests

In general, users can only edit a money request if:

  • in case of IOU report (between regular users):
    • the current user is the requestor and the report is not settled yet.
  • in case of expense report (with a workspace):
    • the current user is the requestor and the report is not settled yet.
    • or the user is an admin on the policy the expense report is tied to.

All other scenarios mean that the users cannot edit a money request.
By the way, once a report is settled, nobody can modify amount, currency nor date (creation date).

IOU report

  1. Open a chat with a regular user.
  2. Create a money request.
  3. Open the details page of the report.
  4. Verify that you can modify all values.
  5. Open the app from the other user account.
  6. Open the same IOU details page.
  7. Verify that you cannot modify any value.
  8. Mark the request as paid.
  9. Verify that nobody can edit any value.

Expense report (admin)

  1. Open a chat with a workspace, where you are an admin.
  2. Create a money request (repeat with different variants: cash, distance, receipt).
  3. Open the details page of the report.
  4. Verify that you can modify all values.
  5. Mark the request as paid.
  6. Verify that you can modify all values, except: amount, currency, date, distance and receipt.

Expense report (member)

  1. Open a chat with a workspace, where you are a member.
  2. Create a money request (repeat with different variants: cash, distance, receipt).
  3. Open the details page of the report.
  4. Verify that you can modify all values.
  5. Mark the request as paid.
  6. Verify that you cannot modify any value.
  • Verify that no errors appear in the JS console

Offline tests

Same as "Tests".

QA Steps

Same as "Tests".

  • 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 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
    • 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(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 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
Expense Opened Admin
Android Expense Opened Admin
Expense Opened Member
Android Expense Opened Member
Expense Paid Admin
Android Expense Paid Admin
Expense Paid Member
Android Expense Paid Member
IOU Opened Requester
Android IOU Opened Requester
IOU Paid Receiver
Android IOU Paid Receiver
Android: mWeb Chrome
Expense Paid Admin
Android Chrome Expense Paid Admin
Expense Paid Member
Android Chrome Expense Paid Member
IOU Opened Requester
Android Chrome IOU Opened Requester
IOU Paid Receiver
Android Chrome IOU Paid Receiver
Expense Opened Admin
Android Chrome Expense Opened Admin
Expense Opened Member
Android Chrome Expense Opened Member
iOS: Native
Expense Opened Admin
IOS Expense Opened Admin
Expense Opened Member
IOS Expense Opened Member
Expense Paid Admin
IOS Expense Paid Admin
Expense Paid Member
IOS Expense Paid Member
IOU Opened Requester
IOS IOU Opened Requester
IOU Paid Receiver
IOS IOU Paid Receiver
iOS: mWeb Safari
Expense Opened Admin
IOS Safari Expense Opened Admin
Expense Opened Member
IOS Safari Expense Opened Member
Expense Paid Admin
IOS Safari Expense Paid Admin
Expense Paid Member
IOS Safari Expense Paid Member
IOU Opened Requester
IOS Safari IOU Opened Requester
IOU Paid Receiver
IOS Safari IOU Paid Receiver
MacOS: Chrome / Safari
Expense Opened Admin
Chrome.Expense.Opened.Member.mp4
Expense Opened Admin
Chrome Expense Opened Admin
Expense Paid Admin
Chrome Expense Paid Admin
Expense Paid Member
Chrome Expense Paid Member
IOU Opened Receiver
Chrome IOU Opened Receiver
IOU Opened Requester
Chrome IOU Opened Requester
IOU Paid Receiver
Chrome IOU Paid Receiver
IOU Paid Requester
Chrome IOU Paid Requester
MacOS: Desktop
Expense Opened Admin
Desktop Expense Opened Admin
Expense Opened Member
Desktop Expense Opened Member
Expense Paid Admin
Desktop Expense Paid Admin
Expense Paid Member
Desktop Expense Paid Member
IOU Opened Requester
Desktop IOU Opened Requester
IOU Paid Receiver
Desktop IOU Paid Receiver

Comment thread src/components/ReportActionItem/MoneyRequestView.js Outdated
Comment thread src/pages/iou/IOUCurrencySelection.js Outdated
@rezkiy37 rezkiy37 marked this pull request as ready for review October 10, 2023 15:58
@rezkiy37 rezkiy37 requested a review from a team as a code owner October 10, 2023 15:58
@melvin-bot melvin-bot Bot requested review from fedirjh and puneetlath and removed request for a team and koko57 October 10, 2023 15:58
@melvin-bot

melvin-bot Bot commented Oct 10, 2023

Copy link
Copy Markdown

@fedirjh @puneetlath One of you needs to 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]

Comment thread src/pages/EditRequestPage.js Outdated
Comment thread src/pages/EditRequestPage.js Outdated
Comment thread src/pages/iou/IOUCurrencySelection.js
@mountiny

Copy link
Copy Markdown
Contributor

@fedirjh Could you please give this one a thorough test 🙇 thanks!

@fedirjh

fedirjh commented Oct 11, 2023

Copy link
Copy Markdown
Contributor

@rezkiy37 Can you please merge main?

@mountiny shouldn’t we handle distance requests in this PR? Server return error when you edit distance after payment is settled

Screenshot 2023-10-11 at 5 35 18 PM

@fedirjh

fedirjh commented Oct 11, 2023

Copy link
Copy Markdown
Contributor

@rezkiy37 App crashes when you deep link to the edit form of a non-existent request eg: http://localhost:8082/r/2961714000886174343/edit/amount

CleanShot.2023-10-11.at.18.58.06.mp4

@rezkiy37

Copy link
Copy Markdown
Contributor Author

Conflicts resolved!

Comment thread src/pages/EditRequestPage.js Outdated
@rezkiy37

Copy link
Copy Markdown
Contributor Author

I've resolved conflicts and @mountiny's comments. Please take a look 🙂

@rezkiy37 rezkiy37 requested a review from mountiny October 18, 2023 10:59
Comment thread src/libs/ReportUtils.js Outdated
@rezkiy37 rezkiy37 requested a review from fedirjh October 18, 2023 13:59
Comment thread src/libs/ReportUtils.js Outdated
@rezkiy37 rezkiy37 requested a review from tgolen October 18, 2023 14:40
tgolen
tgolen previously approved these changes Oct 18, 2023
@rezkiy37

Copy link
Copy Markdown
Contributor Author

@fedirjh, @mountiny, I've resolved all comments. Please take a look.

@mountiny

Copy link
Copy Markdown
Contributor

@fedirjh do you think you could give this one more test

@fedirjh

fedirjh commented Oct 20, 2023

Copy link
Copy Markdown
Contributor

do you think you could give this one more test

Yes, I will re-test it shortly.

@fedirjh fedirjh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-tested and looks good to me.

@melvin-bot melvin-bot Bot requested a review from puneetlath October 20, 2023 20:20

@mountiny mountiny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tim approved previously so going ahead with this one, thanks @fedirjh for retesting

@mountiny mountiny merged commit 22c19f1 into Expensify:main Oct 23, 2023
@OSBotify

Copy link
Copy Markdown
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
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 1.3.90-0 🚀

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

@puneetlath

Copy link
Copy Markdown
Contributor

My apologies for the slowness here. I had jury duty yesterday. Thanks for moving it forward!

@OSBotify

Copy link
Copy Markdown
Contributor

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

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

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 1.3.91-0 🚀

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

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/marcaaron in version: 1.3.91-8 🚀

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

title={transactionDate}
interactive={canEdit}
shouldShowRightIcon={canEdit}
interactive={canEdit && !isSettled}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Curious why we didn't use here canEditFieldOfMoneyRequest and pass the date field to it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looks like we actually can use canEditFieldOfMoneyRequest for those 3 specific fields of MoneyRequestView.
@youssef-lr, can I create a follow up PR for the issue - #28963?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's okay, I'm working on this issue and will include this update.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Coo, thank you!

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.

9 participants