Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix - Don't show RBR on the LHN for transaction threads with violations if the report has already been reimbursed/settled #37767

Merged

Conversation

FitseTLT
Copy link
Contributor

@FitseTLT FitseTLT commented Mar 5, 2024

Details

Fixed Issues

$ #34548
PROPOSAL: #34548 (comment)

Tests

Precondition:
Make sure you're on the violations beta
On the collect workspace set category as required

  1. Request money without adding a category from the workspace (it should have a missing category violation)
  2. Submit the request if you need to
  3. pay (reimburse) the request as a workspace admin so that the request is set as settled/payed
  4. Open the transaction thread as the requester. You may need to navigate to another chat, and then back to the transaction thread
  5. Verify that RBR (Red Dot) no more shows on LHN for the transaction thread report
  • Verify that no errors appear in the JS console

Offline tests

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 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 any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
android.mp4
Android: mWeb Chrome
android.web.mp4
iOS: Native
ios.mp4
iOS: mWeb Safari
ios.web.mp4
MacOS: Chrome / Safari
2024-03-20.23-36-57.mp4
MacOS: Desktop
2024-03-20.23-40-52.mp4

@FitseTLT FitseTLT requested a review from a team as a code owner March 5, 2024 15:33
@melvin-bot melvin-bot bot requested review from situchan and removed request for a team March 5, 2024 15:33
Copy link

melvin-bot bot commented Mar 5, 2024

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

src/libs/SidebarUtils.ts Outdated Show resolved Hide resolved
src/libs/SidebarUtils.ts Outdated Show resolved Hide resolved
@FitseTLT FitseTLT requested a review from cead22 March 5, 2024 16:41
@cead22
Copy link
Contributor

cead22 commented Mar 5, 2024

Code looks good. I'll wait for @situchan to review before approving

@quinthar
Copy link
Contributor

quinthar commented Mar 8, 2024

Hi, what's the ETA on this? Eager to get it done!

@situchan
Copy link
Contributor

situchan commented Mar 8, 2024

completing today

let shouldShowViolations = false;
if (hasViolations && parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU) {
const {IOUReportID} = parentReportAction?.originalMessage ?? {};
shouldShowViolations = !ReportUtils.isSettled(IOUReportID);
Copy link
Contributor

Choose a reason for hiding this comment

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

I am still seeing RBR after approve request

Screenshot 2024-03-08 at 7 23 01 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

@cead22 should we show RBR when approved but not reimbursed?

ReportUtils has isReportApproved (statusNum = APPROVED) and isSettled (statusNum = REIMBURSED) methods.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes

  • On the LHN only to the user that made the request
  • On the money request view, to all users that have access

Copy link
Contributor

Choose a reason for hiding this comment

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

On the LHN only to the user that made the request

🟢

On the money request view, to all users that have access

I am not seeing violation on payer side

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not seeing violation on payer side

That's probably because RequestMoney doesn't return violations, and doesn't push them to the relevant users either. There's another issue that OpenReport only returns violations to the user that made the money request.

I submitted a backend fix for the second issue, and I'm working on a backend solution for the first as well

@situchan
Copy link
Contributor

situchan commented Mar 8, 2024

@FitseTLT please update Tests / QA step as per #37767 (comment).
Currently it's wrong.
We should still show RBR for approved requests (but not reimbursed).
Also, please update videos accordingly.

@FitseTLT
Copy link
Contributor Author

FitseTLT commented Mar 8, 2024

@FitseTLT please update Tests / QA step as per #37767 (comment). Currently it's wrong. We should still show RBR for approved requests (but not reimbursed). Also, please update videos accordingly.

By the way, I know and the reason I said approved or payed is to cover the condition of auto-reimbursement but I have now updated it to avoid confusion. But the snapshots are correct.

@situchan
Copy link
Contributor

situchan commented Mar 8, 2024

@FitseTLT though RBR doesn't show on LHN, it looks as if pinned. It should be below pinned items

Screenshot 2024-03-09 at 12 48 05 AM

@situchan
Copy link
Contributor

@FitseTLT bump on above.
I suggest you to give priority to pending PRs over submitting proposals on new issues.

@FitseTLT FitseTLT requested a review from situchan March 11, 2024 16:04
@FitseTLT
Copy link
Contributor Author

Fixed 👍

@FitseTLT
Copy link
Contributor Author

@situchan can u please give it a priority as it is considered a highly requested issue

@situchan
Copy link
Contributor

@FitseTLT can you please update screen recording after applying that fix?

@FitseTLT though RBR doesn't show on LHN, it looks as if pinned. It should be below pinned items

For this bug, one platform re-testing is fine

@quinthar
Copy link
Contributor

Yes, can't wait for this one.

@@ -4048,7 +4048,8 @@ function doesTransactionThreadHaveViolations(report: OnyxEntry<Report>, transact
if (report?.stateNum !== CONST.REPORT.STATE_NUM.OPEN && report?.stateNum !== CONST.REPORT.STATE_NUM.SUBMITTED) {
return false;
}
return TransactionUtils.hasViolation(IOUTransactionID, transactionViolations);

return TransactionUtils.hasViolation(IOUTransactionID, transactionViolations) && !isSettled(IOUReportID);
Copy link
Contributor

@cead22 cead22 Mar 14, 2024

Choose a reason for hiding this comment

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

Can we move this call to isSettled outside of this function like in the proposal? I don't think it belongs in this function

@FitseTLT
Copy link
Contributor Author

revert pr #38081 has made the last change unnecessary. I will revert it.

@FitseTLT
Copy link
Contributor Author

@cead22 I have a question on

Can we move this call to isSettled outside of this function like in the proposal? I don't think it belongs in this function

Except the one we are dealing with here (showing RBR of LHN) there are two instances we use doesTransactionThreadHaveViolations

const doesReportHaveViolations =
(betas?.includes(CONST.BETAS.VIOLATIONS) && ReportUtils.doesTransactionThreadHaveViolations(report, transactionViolations, parentReportAction)) ?? false;

const doesReportHaveViolations =
betas.includes(CONST.BETAS.VIOLATIONS) && !!parentReportAction && ReportUtils.doesTransactionThreadHaveViolations(report, transactionViolations, parentReportAction);

and in both case we pass it to shouldReportBeInOptionList but in shouldReportBeInOptionList violations will only affect the result when the transaction(report) is not settled we alread have isSettled Check here

App/src/libs/ReportUtils.ts

Lines 4225 to 4228 in e9c112a

const reportIsSettled = report.statusNum === CONST.REPORT.STATUS_NUM.REIMBURSED;
// Always show IOU reports with violations unless they are reimbursed
if (isExpenseRequest(report) && doesReportHaveViolations && !reportIsSettled) {

And in fact the appearance of settled report along with the pinned ones bug (the one @situchan ) reported was caused by the lack of isSettled check on here (but now it is reverted)
if (doesReportHaveViolations) {
reportIDsWithViolations.add(report.reportID);
}

Questions:

  1. So I fear that not centralizing the isSettled check here will cause problems than putting the check inside it. may be let's update the name of the function by adding sth like should display or sth.
  2. The isSettled check we have here

    App/src/libs/ReportUtils.ts

    Lines 4225 to 4226 in e9c112a

    const reportIsSettled = report.statusNum === CONST.REPORT.STATUS_NUM.REIMBURSED;

    check if it is reimbursed but our isSettled function also assumes it is settled if it is approved and we are waiting for the employee bank account to be set. So which one is the path we should follow (I prefer the ReportUtils.isSettled one)

App/src/libs/ReportUtils.ts

Lines 749 to 752 in 0e9bd7f

// In case the payment is scheduled and we are waiting for the payee to set up their wallet,
// consider the report as paid as well.
if (report.isWaitingOnBankAccount && report.statusNum === CONST.REPORT.STATUS_NUM.APPROVED) {
return true;

@cead22
Copy link
Contributor

cead22 commented Mar 15, 2024

Discussing this with @JmillsExpensify, I think we want to do something slightly different, and I'll update the issue to reflect this. Let me make sure I got the requirements right and I'll update here

@cead22
Copy link
Contributor

cead22 commented Mar 19, 2024

@FitseTLT sorry for the delay

  • So I fear that not centralizing the isSettled check here will cause problems than putting the check inside it. may be let's update the name of the function by adding sth like should display or sth.

I'm good with adding a function like you suggest shouldDisplayViolationsRBRInLHN = (...) => ReportUtils.doesTransactionThreadHaveViolations(...) && ! isSettled(...)

2. check if it is reimbursed but our isSettled function also assumes it is settled if it is approved and we are waiting for the employee bank account to be set. So which one is the path we should follow (I prefer the ReportUtils.isSettled one)

ReportUtils.isSettled sounds good 👍

@FitseTLT
Copy link
Contributor Author

@situchan ready for your review!

src/components/LHNOptionsList/OptionRowLHNData.tsx Outdated Show resolved Hide resolved
src/libs/ReportUtils.ts Outdated Show resolved Hide resolved
src/libs/ReportUtils.ts Outdated Show resolved Hide resolved
src/libs/ReportUtils.ts Outdated Show resolved Hide resolved
@situchan
Copy link
Contributor

Reviewer Checklist

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

Screenshots/Videos

Android: Native
android.mov
Android: mWeb Chrome
mchrome.mov
iOS: Native
ios.mov
iOS: mWeb Safari
msafari.mov
MacOS: Chrome / Safari web
MacOS: Desktop desktop

Copy link
Contributor

@situchan situchan left a comment

Choose a reason for hiding this comment

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

Let's just address Carlos's feedback

@melvin-bot melvin-bot bot requested a review from cead22 March 21, 2024 01:37
@FitseTLT
Copy link
Contributor Author

@cead22 All comments addressed and changes test well 👍

@cead22 cead22 merged commit 715714c into Expensify:main Mar 21, 2024
14 of 15 checks passed
@melvin-bot melvin-bot bot added the Emergency label Mar 21, 2024
Copy link

melvin-bot bot commented Mar 21, 2024

@cead22 looks like this was merged without a test passing. Please add a note explaining why this was done and remove the Emergency label if this is not an emergency.

@cead22
Copy link
Contributor

cead22 commented Mar 21, 2024

Tests pass, but performance tests are running, but they take a long time and will alert if it fails. This wasn't an emergency change

@cead22 cead22 removed the Emergency label Mar 21, 2024
@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/cead22 in version: 1.4.56-0 🚀

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

@sakluger
Copy link
Contributor

Hey guys, unfortunately, this doesn't appear to have fixed the issue for me. I signed out and back into staging.new.expensify.com, and when everything finished loading, all the individual report chats were still in my LHN, without the RBR dot now. When I clicked on any of them, the RBR dot returned.

Here's what it looks like after I have clicked on two of the report chats:

image

@situchan
Copy link
Contributor

Hey guys, unfortunately, this doesn't appear to have fixed the issue for me. I signed out and back into staging.new.expensify.com, and when everything finished loading, all the individual report chats were still in my LHN, without the RBR dot now. When I clicked on any of them, the RBR dot returned.

Here's what it looks like after I have clicked on two of the report chats:

image

Do you mind sharing full video of that request (expense report, transaction detail)?

@cead22
Copy link
Contributor

cead22 commented Mar 26, 2024

Can you also share the transaction thread reportIDs (if you're looking at the money request page, where you can edit category/tag/etc, it's the ID in the URL)

@FitseTLT
Copy link
Contributor Author

@cead22 From the explanation #37767 (comment) It looks like the issue is that the iouReport haven't been loaded to onyx but unfortunately for now when iou Report is approved/settled we are not setting the transaction thread reports statusNum so to determine whether it is settled we need to depend on the status of the iou report which is another report so whenever it is not in onyx this cases can occur.

@cead22
Copy link
Contributor

cead22 commented Mar 26, 2024

Thanks @FitseTLT, let me know if you find a way to reproduce, since I haven't been able to

  • I disabled a category that's set on requests that are settled
  • Signed out and back in to try to get the transaction threads to load without their parent report
  • I tried focus and most recent mode

@cead22
Copy link
Contributor

cead22 commented Mar 26, 2024

@cead22
Copy link
Contributor

cead22 commented Mar 26, 2024

Here are some log requestIDs Sasha pulled from the Network tab from when I clicked on one of the report chats:

  • OpenReport: 86a8a5f2191ffa8a-SJC
  • Ping: 86a8a5f42b1afa8a-SJC
  • AuthenticatePusher: 86a8a5f43b2efa8a-SJC
  • OpenReport: 86a8a5f54c40fa8a-SJC
  • SendPerformanceTiming: 86a8a5f65d84fa8a-SJC
  • Log: 86a8a5fbbab5fa8a-SJC

@cead22
Copy link
Contributor

cead22 commented Mar 26, 2024

I tried disabling tags as well, and still couldn't repro

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/yuwenmemon in version: 1.4.56-8 🚀

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

parentReportAction: OnyxEntry<ReportAction>,
): boolean {
const {IOUReportID} = (parentReportAction?.originalMessage as IOUMessage) ?? {};
if (isSettled(IOUReportID)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Later, we added more condition (approved reports, not only reimbursed/settled) to hide RBR on the LHN for transaction threads.
#45230

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