Skip to content

Create report flow follow ups #59386

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

Conversation

SzymczakJ
Copy link
Contributor

@SzymczakJ SzymczakJ commented Mar 31, 2025

Explanation of Change

Expanation of changes:

  1. Added another condition to show Create report button in FloatingActionButtonAndPopover.
  2. Added another option in AttachmentPickerWithMenuItems to enable creating reports from eligible workspace chats.
  3. Added OfflineWithFeedback component to MoneyRequestReportView to handle offline state and failure state(along with fixing report optimistic data, some error utils functions and dismiss error function)
  4. Added tests that were requested in [Due for payment 2025-04-23] [Due for payment 2025-04-16] [Report Creation UI] Follow up tasks #59295
  5. Had to move prepareOnboardingOnyxData from Report.ts to ReportUtils.ts to fix linter, after all I also think this is a helper function and it belongs there.
  6. Had to create custom navigation go back in MoneyRequestReportView to handle handle specific case when we are creating a report -> selecting a workspace for it -> dismissing creation error -> we need to get navigated to the previous page.

Fixed Issues

$ #59295
$ #59425
$ #59339
$ #59459
PROPOSAL:

Tests

  1. Test fix for: There is option to Create Report in FAB when no workspaces are present
    Have all beta permissions and no workspaces on the account, open up FAB and make sure there is no create report option.
  2. Test fix for: No create report option in workspace chat
    Have a workspace that is a paid group workspace and has chat enabled, open up a workspace chat and try to create report with plus buttonnext to the composer.
  3. Test if New expenses added from the report view page doesn't get updated in the table of the report view. does not reproduce.
  4. Test if No option to add expense if report is created offline does not reproduce.
  5. Test if [Due for payment 2025-04-16] [Report Creation UI] QAB - Workspace name under "Create expense" does not update after changing display name #59425 doe not reproduce: simply create expense -> change user display name -> make sure quick action button has a name updated.
  6. Test offline report creation: turn on offline mode -> create report -> make sure it on 50% opacity -> make sure that after coming back online the report opacity is gone.
  7. Test failure state in report creation: turn on failing requests -> create report -> make sure that the composer is gone and error shows up -> make sure that after dimissing error the report is deleted.

Offline tests

Point 10. of tests.

QA Steps

Note: to test all of these fixes you have to have tableReportView permission

  • Test fix for: There is option to Create Report in FAB when no workspaces are present
  1. Have an account no workspaces on it.
  2. Click on Fab and make sure there is no "Create report" option
  • Test fix for: No create report option in workspace chat
  1. Have a workspace that is a paid group workspace and has chat enabled.
  2. Open up this workspace chat and try to create report with plus button next to the composer
  • Test fix for: New expenses added from the report view page doesn't get updated in the table of the report view
  1. Open search report view page(it's this one)
Screenshot 2025-04-07 at 11 09 10 2. Create expense with plus button and make sure it appears on the table view. - Test fix for: https://github.com//issues/59425 1. Create expense with FAB 2. Change user display name 3. Make sure quick action button has a name updated. - Test offline report creation: 1. Turn on offline mode 2. Create report 3. make sure report view page is on 50% opacity 4. Make sure that after coming back online the report opacity is gone. - Test failure state in report creation: 1. turn on failing requests 2. Create report 3. Make sure that the composer is gone and error shows up 4. Make sure that after dimissing error the report is deleted.

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 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.mov
Android: mWeb Chrome
andweb.mov
iOS: Native
io1.mov
ios2.mov
iOS: mWeb Safari
iosweb.mov
iosweb2.mov
MacOS: Chrome / Safari
webp1.mov
web2.mov
MacOS: Desktop
desktop.mov
desktop2.mov

statusNum,
total: 0,
nonReimbursableTotal: 0,
participants: {},
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe declare it earlier like this:

const participants = accountId ?? {
    [accountID]: {
        notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
    },
} : {};

optimisticEmptyReport.ownerAccountID = accountID;
is declared twice, so we can omit it in the if (accountID), and as a result, the entire if can be removed.

@SzymczakJ SzymczakJ force-pushed the @szymczak/create-report-flow-follow-up branch from 758fbb3 to 4010be4 Compare April 3, 2025 13:05
@SzymczakJ SzymczakJ marked this pull request as ready for review April 3, 2025 13:20
@SzymczakJ SzymczakJ requested a review from a team as a code owner April 3, 2025 13:20
@melvin-bot melvin-bot bot requested review from allgandalf and removed request for a team April 3, 2025 13:20
Copy link

melvin-bot bot commented Apr 3, 2025

@allgandalf 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

github-actions bot commented Apr 3, 2025

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

@@ -3929,558 +3915,6 @@ function getReportPrivateNote(reportID: string | undefined) {
API.read(READ_COMMANDS.GET_REPORT_PRIVATE_NOTE, parameters, {optimisticData, successData, failureData});
}

function prepareOnboardingOnyxData(
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we moving this out of the the actions folder ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How it happened:

  1. I had to add tests, but I wasn't able to make them pass, because of wrong imports across the app, so I had to fix these imports.
  2. wrong imports: prepareOnboardingOnyxData function was located in Report.ts -> it was imported in ReportUtils.ts -> it was reexported from ReportUtils.ts and used in Policy.ts, so that we don't get a linter warning "you cannot use action in another action"(for linter action is a function exported from actions folder).
    This combination of import was for some reason making jest fail my tests, when I was trying to mock ReportUtils.ts in ReportTest.ts

So now it is fixed: prepareOnboardingOnyxData is no longer in Report.ts, but its in ReportUtils.ts. That way we don't have the import + export that was breaking jest tests.
Does this make sense? 😄 If not I'll try to explain it more plainly.

Copy link
Contributor

Choose a reason for hiding this comment

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

understood, we need to document these changes for sure though!, lets look at it in a followup NAB

Comment on lines 2649 to 2656
/**
* Removes report, it's related report actions and next step from Onyx.
*/
function removeReport(reportID: string | undefined) {
Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, null);
Onyx.set(`${ONYXKEYS.COLLECTION.NEXT_STEP}${reportID}`, null);
Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, null);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

where do we call the API?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is deletion of optimistic report that failed to create, so it's not even present on BE.
I'll edit function comment: Removes the report after failure to create. Also removes it's related report actions and next step from Onyx. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

or rename the function to removeFailedReport

Copy link
Contributor

Choose a reason for hiding this comment

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

or rename the function to removeFailedReport

I like this idea, the current name confused me at first glance

Comment on lines +281 to +283
// eslint-disable-next-line react-compiler/react-compiler
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [hideQABSubtitle, personalDetails, quickAction?.action, quickActionPolicy?.name, quickActionReport, translate]);
Copy link
Contributor

Choose a reason for hiding this comment

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

whyyy do we need to suppress these ones ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes this bug #59425.
Some of the functions getting QA subtitle(getReportName) are using OnyxConnect and therefore do not get updated when user changes display name. To fix it we need to also add personalDetails as a dependency of this useMemo.

Linter is unhappy, because it doesn't see any usage of personalDetails in the hook, but actually personalDetails are used under the hood and we need to recompute useMemo, when they change.

That's why I suppress the warnings. Previously it was working, because we didn't use any useMemo, but I think it's better to have it here, even if we suppress these warnings.

Copy link
Contributor

Choose a reason for hiding this comment

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

@SzymczakJ NAB but could you add a comment about the personal details being used under the hood as it might not obvious immediately and this will also help explain why we have the es linter skips

@SzymczakJ
Copy link
Contributor Author

You might want to read the Expanation of changes section in PR description @allgandalf. Left some notes there, so it's easier to review this PR.

@allgandalf
Copy link
Contributor

allgandalf commented Apr 4, 2025

  • Test fix for: There is option to Create Report in FAB when no workspaces are present
    ✅ Have all beta permissions and no workspaces on the account, open up FAB and make sure there is no create report option.

  • Test fix for: No create report option in workspace chat
    ✅ Have a workspace that is a paid group workspace and has chat enabled, open up a workspace chat and try to create report with plus buttonnext to the composer.

  • ✅ Test if New expenses added from the report view page doesn't get updated in the table of the report view. does not reproduce.

  • 🔴 ❎ Test if No option to add expense if report is created offline does not reproduce.
Screen.Recording.2025-04-04.at.9.55.56.PM.mov


  • ✅ Test offline report creation: turn on offline mode -> create report -> make sure it on 50% opacity -> make sure that after coming back online the report opacity is gone.

  • ✅ Test failure state in report creation: turn on failing requests -> create report -> make sure that the composer is gone and error shows up -> make sure that after dimissing error the report is deleted.

@allgandalf
Copy link
Contributor

allgandalf commented Apr 4, 2025

Bug: I cannot see the report preview in workspace chat when creating the expense from workspace chat? is this expected?:

Will be fixed in http://github.com/Expensify/App/issues/59502

Copy link
Contributor

@allgandalf allgandalf left a comment

Choose a reason for hiding this comment

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

code wise this is great! we already improved in a lot of places, the ^ reported bugs can be dealt with in a follow up i think and we should merge this one as it already fixes a bunch of cases

}
type SkipViewTourOnboardingChoices = 'newDotSubmit' | 'newDotSplitChat' | 'newDotPersonalSpend' | 'newDotEmployer';
if (
task.type === 'viewTour' &&
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use a const here

Copy link
Contributor

Choose a reason for hiding this comment

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

@luacmartins that code was just moved from the actions file, so we decided not to make any changes related to it

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea, I agree that's cleaner that way. Just noting that we could clean this up later.

const completedTaskReportAction = task.autoCompleted
? buildOptimisticTaskReportAction(currentTask.reportID, CONST.REPORT.ACTIONS.TYPE.TASK_COMPLETED, 'marked as complete', actorAccountID, 2)
: null;
if (task.type === 'createWorkspace') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

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.

Just couple of NABs, great job!

Comment on lines +281 to +283
// eslint-disable-next-line react-compiler/react-compiler
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [hideQABSubtitle, personalDetails, quickAction?.action, quickActionPolicy?.name, quickActionReport, translate]);
Copy link
Contributor

Choose a reason for hiding this comment

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

@SzymczakJ NAB but could you add a comment about the personal details being used under the hood as it might not obvious immediately and this will also help explain why we have the es linter skips

@@ -75,6 +75,35 @@ describe('libs/NextStepUtils', () => {
Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, policy).then(waitForBatchedUpdates);
});

describe('it generates and optimistic nextStep once a report has been created', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
describe('it generates and optimistic nextStep once a report has been created', () => {
describe('it generates an optimistic nextStep once a report has been created', () => {

@mountiny mountiny merged commit 9168f58 into Expensify:main Apr 5, 2025
18 of 23 checks passed
@OSBotify
Copy link
Contributor

OSBotify commented Apr 5, 2025

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

Copy link
Contributor

github-actions bot commented Apr 7, 2025

🚀 Deployed to staging by https://github.com/mountiny in version: 9.1.24-2 🚀

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

@mvtglobally
Copy link

@luacmartins @DylanDylann @mountiny How do we enable "tableReportView" to run this PR?

@DylanDylann
Copy link
Contributor

cc @allgandalf

@SzymczakJ
Copy link
Contributor Author

@luacmartins @DylanDylann @mountiny How do we enable "tableReportView" to run this PR?

It's "tableReportView" beta, from what I know every tester has all the permissions, so you don't need to worry about that. If you see a Create report button in your FAB for account that has a paid workspace, then you know you have it.

@mountiny
Copy link
Contributor

mountiny commented Apr 8, 2025

@mvtglobally any applause tester on your domain has it enabled - public domains do not have the beta

@vincdargento
Copy link

@SzymczakJ This PR is failing because of issue #59853
The issue is reproducible in: Web, Desktop, mWeb, iOS

bug.mp4

Copy link
Contributor

github-actions bot commented Apr 9, 2025

🚀 Deployed to production by https://github.com/jasperhuangg in version: 9.1.24-10 🚀

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

Copy link
Contributor

github-actions bot commented Apr 9, 2025

🚀 Deployed to production by https://github.com/jasperhuangg in version: 9.1.24-10 🚀

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

onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${currentTask.reportID}`,
value: {
[taskCreatedAction.reportActionID]: {pendingAction: null},
Copy link
Contributor

Choose a reason for hiding this comment

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

We forgot to set isOptimisticAction to null for tasks, textComment, and welcomeSignOffCommentAction in the success data. This caused this issue #60833 where, after creating tasks and going offline, the tasks appeared grayed out. Context: #60833 (comment)

@@ -2637,14 +2604,24 @@ function buildNewReportOptimisticData(policy: OnyxEntry<Policy>, reportID: strin
},
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReport?.reportID}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

this caused this regression: #61500

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.

10 participants