Skip to content

[CP Staging] Fix blinking old type of report #62562

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

Merged

Conversation

martasudol
Copy link
Contributor

@martasudol martasudol commented May 22, 2025

Explanation of Change

This PR fixes an empty state or expenses preview shown briefly when opening transaction thread.

Fixed Issues

$ #62514

Tests

  1. Go to Reports > Expense Reports
  2. Click a row that's just a single row
  3. After skeleton loader, you should see complete data view, without blinking empty state or expense preview components.
  • Verify that no errors appear in the JS console

Offline tests

n/a

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 verified there are no new alerts related to the canBeMissing param for useOnyx
  • 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 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 used JaimeGPT to get English > Spanish translation. I then posted it 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.ts 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.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
Nagranie.z.ekranu.2025-05-22.o.12.59.38.mov
MacOS: Chrome / Safari
Nagranie.z.ekranu.2025-05-22.o.12.56.23.mov
MacOS: Desktop

Copy link
Contributor

🚧 @mountiny has triggered a test app build. You can view the workflow run here.

@mountiny mountiny self-requested a review May 22, 2025 10:20
@mountiny mountiny changed the title Fix blinking old type of report [CP Staging] Fix blinking old type of report May 22, 2025
Copy link
Contributor

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

Android 🤖 iOS 🍎
Android 🤖🔄 iOS 🍎🔄
Android iOS
Desktop 💻 Web 🕸️
❌ FAILED ❌ https://62562.pr-testing.expensify.com
The QR code can't be generated, because the Desktop build failed Web

👀 View the workflow run that generated this build 👀

@mountiny mountiny requested a review from DylanDylann May 22, 2025 11:42
@martasudol martasudol marked this pull request as ready for review May 22, 2025 11:55
@martasudol martasudol requested a review from a team as a code owner May 22, 2025 11:55
@melvin-bot melvin-bot bot requested review from marcaaron and removed request for a team May 22, 2025 11:56
Copy link

melvin-bot bot commented May 22, 2025

@marcaaron Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

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

In general once we get rid of the table report view beta, I think we should take another look at this if the logic can be simplified. for now its very fragile and not easy to follow cc @Kicu

Thanks for a quick fix and seems to work well for me, video here: https://expensify.slack.com/archives/C01GTK53T8Q/p1747916319905749?thread_ts=1747859807.859029&cid=C01GTK53T8Q

@mountiny
Copy link
Contributor

mountiny commented May 22, 2025

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 that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • 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 there are no new alerts related to the canBeMissing param for useOnyx
  • 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 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.ts 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.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • 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: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop

@mountiny
Copy link
Contributor

@SzymczakJ @martasudol also tested so I will move this one ahead and ask QA for a retest

@mountiny mountiny merged commit e48ca86 into Expensify:main May 22, 2025
19 checks passed
OSBotify pushed a commit that referenced this pull request May 22, 2025
…pe-of-report

[CP Staging] Fix blinking old type of report

(cherry picked from commit e48ca86)

(cherry-picked to staging by mountiny)
@OSBotify OSBotify added the CP Staging marks PRs that have been CP'd to staging label May 22, 2025
@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.

// Prevent flash by ensuring transaction data is fully loaded before deciding which view to render
// We need to wait for both the selector to finish AND ensure we're not in a loading state where transactions could still populate
const isTransactionDataReady = transactions !== undefined;
const isStillLoadingData = !!isLoadingInitialReportActions || !!reportMetadata?.isLoadingOlderReportActions || !!reportMetadata?.isLoadingNewerReportActions;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we check for reportMetadata?.isLoadingOlderReportActions and reportMetadata?.isLoadingNewerReportActions?
I've found one case(it was really hard to reproduce it 😄 ) when:

  1. We are already on empty report which is loaded
  2. for some reason loadNewerChats from MoneyRequestReportActionsList fires and makes reportMetadata?.isLoadingNewerReportActions true
  3. because of that InitialLoadingSkeleton flashes for a moment

Copy link
Contributor

🚀 Cherry-picked to staging by https://github.com/mountiny in version: 9.1.49-6 🚀

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

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

Copy link
Contributor

🚀 Deployed to production by https://github.com/arosiclair in version: 9.1.50-0 🚀

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

// We need to wait for both the selector to finish AND ensure we're not in a loading state where transactions could still populate
const isTransactionDataReady = transactions !== undefined;
const isStillLoadingData = !!isLoadingInitialReportActions || !!reportMetadata?.isLoadingOlderReportActions || !!reportMetadata?.isLoadingNewerReportActions;
const shouldWaitForData = (!isTransactionDataReady || (isStillLoadingData && transactions?.length === 0)) && !isTransactionThreadView;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we check for transactions?.length === 0? It's possible to have an empty report

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initially, when transactions come from Onyx, they are an empty array - not undefined. So the check for transactions?.length === 0 helps us distinguish between "data is ready but empty" vs "data is still loading".

@dmkt9
Copy link
Contributor

dmkt9 commented May 24, 2025

I think this PR causes infinite loading after creating a report while offline

@martasudol
Copy link
Contributor Author

I think this PR causes infinite loading after creating a report while offline

@dmkt9 could you help me reproduce it? Take a look on my recording 👇

Nagranie.z.ekranu.2025-05-27.o.14.33.15.mov

@dmkt9
Copy link
Contributor

dmkt9 commented May 27, 2025

@martasudol Sure. Below is the video I reproduced. The error seems to originate here, with isLoadingInitialReportActions always being true when offline. I hope it helps you somewhat:

const isStillLoadingData = !!isLoadingInitialReportActions || !!reportMetadata?.isLoadingOlderReportActions || !!reportMetadata?.isLoadingNewerReportActions;
const shouldWaitForData = (!isTransactionDataReady || (isStillLoadingData && transactions?.length === 0)) && !isTransactionThreadView;

msedge_327LHLY1cl.mp4

@martasudol
Copy link
Contributor Author

@dmkt9 thanks! I'm on it!

@martasudol
Copy link
Contributor Author

@dmkt9 I've added isOffline flag to the condition, now we don't have infinite skeleton loader but it looks like this 👇 Is it correct? 🤔

Zrzut ekranu 2025-05-28 o 08 31 39

@SzymczakJ
Copy link
Contributor

@martasudol
Copy link
Contributor Author

@SzymczakJ no problem, just let me know what should change in app behavior so I could test if it works well 🤞

Also @SzymczakJ maybe you're able to help me understand what's the expected behavior here? :D

@SzymczakJ
Copy link
Contributor

I think our expected behaviour for offline mode is to not show any loading indicator, since nothing is being loaded. So in our case it would be showing just "This report has no expenses" empty state. cc @shawnborton for confirmation 🙏
Changes suggested in my previous comment should fix that.

@martasudol
Copy link
Contributor Author

You mean

ListEmptyComponent={(isLoadingInitialReportActions && !isOffline) ? <ReportActionsListLoadingSkeleton /> : undefined} // This skeleton component is only used for loading state, the empty state is handled by SearchMoneyRequestReportEmptyState

? If so, unfortunately it doesn't change anything in the flow described by @dmkt9 👇

Nagranie.z.ekranu.2025-05-28.o.10.28.09.mov

@shawnborton
Copy link
Contributor

Hmm but in this case, do we actually know for sure that the report has no expenses?
CleanShot 2025-05-28 at 10 30 01@2x

If we aren't sure if the report has no expenses or not, we should use a more generic skeleton loader - otherwise that empty state might be very misleading.

@martasudol
Copy link
Contributor Author

Hmm but in this case, do we actually know for sure that the report has no expenses?

We don't. IMO in this case we should show skeleton loader as we do for other reports (static one; without animation). What do you think @shawnborton?

@shawnborton
Copy link
Contributor

Yup, that makes sense to me.

@martasudol
Copy link
Contributor Author

Cool. PR created. Waiting for pipes to make it ready for review.

@SzymczakJ looks like your missing flag doesn't break anything :D

@SzymczakJ
Copy link
Contributor

Hmm but in this case, do we actually know for sure that the report has no expenses?

There is one case in which we know that the report has no expenses: when we create and empty report in offline mode.

Screen.Recording.2025-05-28.at.12.21.49.mov

If we block it by big skeleton then the user won't have an option to create any expenses offline in this report. Isn't that a problem?

@dmkt9
Copy link
Contributor

dmkt9 commented May 28, 2025

If we block it by big skeleton then the user won't have an option to create any expenses offline in this report. Isn't that a problem?

@martasudol @SzymczakJ @shawnborton I think so too. I see that there are quite a few flows running in offline mode. And the issue has been reported here #62677

@martasudol
Copy link
Contributor Author

Do you think it should be handled in #62677?

@shawnborton
Copy link
Contributor

There is one case in which we know that the report has no expenses: when we create and empty report in offline mode. If we block it by big skeleton then the user won't have an option to create any expenses offline in this report. Isn't that a problem?

I agree we wouldn't want to block it in that case. The whole point of the "Report is empty" empty state isn't to be any kind of loading state, it's truly only to be shown when the report is empty. So if you create a report while offline and you haven't added any expenses to it, we should definitely show it.

@SzymczakJ
Copy link
Contributor

SzymczakJ commented May 28, 2025

Okay, I think this discussion got a little messy and we should just define the UI states for each edge case:

  1. We are in offline mode, we create a report and open it
    We should be showing this UI state right @shawnborton?
Screenshot 2025-05-28 at 17 13 45

Currently we are just showing the generic loading page, which is blocking users from making expenses in offline mode.

  1. We created a report and added expenses to it and they got loaded to onyx, but now we are offline
    Currently we are showing list of transactions and loading report actions loading state
Screenshot 2025-05-28 at 17 17 50

But I suggest we get rid of that infinite loading state, while we are offline

  1. We created a report in online mode and then went offline without adding any expenses
    Currently we are showing this, should we get rid of the report actions loading state, or leave it as it is?
Screenshot 2025-05-28 at 17 29 36

WDYT @shawnborton
Is there any other offline state/loading state edge case? @martasudol @dmkt9

@shawnborton
Copy link
Contributor

  1. Looks correct to me
  2. Agree, I feel like no need for the skeleton loader below the table, because comments will never load while offline
  3. Also agree we should get rid of that loader, because comments are simply not going to load here.

cc @Expensify/design @trjExpensify for a gut check too.

@trjExpensify
Copy link
Contributor

trjExpensify commented May 28, 2025

Agree on those.

We created a report and added expenses to it and they got loaded to onyx, but now we are offline
Currently we are showing list of transactions and loading report actions loading state

Additionally though, did you create the report and add these two expenses all while offline in this case?

image

@dubielzyk-expensify
Copy link
Contributor

See that this merged, but agree with the comments above

@SzymczakJ
Copy link
Contributor

Additionally though, did you create the report and add these two expenses all while offline in this case?

I created the report and added these two expenses online and then switched to offline mode before opening Report.

@martasudol do you mind, if we take over the #62677 and finish that empty state in there? We will probably have extra bandwidth today, so we will be looking for something to work on 😄

@martasudol
Copy link
Contributor Author

No problem, @SzymczakJ - go ahead! I also think it's a good idea, since you've been working on this codebase and have more context. If I can help with anything, just let me know!

@trjExpensify
Copy link
Contributor

I created the report and added these two expenses online and then switched to offline mode before opening Report.

Cool, all good then. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CP Staging marks PRs that have been CP'd to staging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants