Skip to content

Feature/kuba nowakowski/add empty state to expense view #58795

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

sumo-slonik
Copy link
Contributor

@sumo-slonik sumo-slonik commented Mar 20, 2025

Explanation of Change

The created PR adds an empty state for the new report view and fixes a bug related to displaying two reports in the workspace.

Fixed Issues

$ #57654
$ #58426
$ #58425

$
PROPOSAL:

Tests

  1. Click the FAB.
  2. Click "Create Report."
  3. Check if the empty state looks good.
  4. Check if only one report appears in the workspace after creating it.
  • Verify that no errors appear in the JS console

Offline tests

unnecessary

QA Steps

Same as test

  • 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 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
Screen.Recording.2025-03-20.at.14.45.18.mov
Android: mWeb Chrome
Screen.Recording.2025-03-20.at.14.51.28.mov
iOS: Native

Uploading Screen Recording 2025-03-20 at 15.51.45.mov…

iOS: mWeb Safari
Screen.Recording.2025-03-20.at.14.51.28.mov
MacOS: Chrome / Safari
Screen.Recording.2025-03-20.at.14.07.55.mov
MacOS: Desktop
Screen.Recording.2025-03-20.at.14.07.55.mov

@@ -346,6 +346,9 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
if (hasScanningReceipt) {
return {icon: getStatusIcon(Expensicons.ReceiptScan), description: translate('iou.receiptScanInProgressDescription')};
}
if (isEmpty) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if this should be done this way or as the expected optimistic next step. I did it this way because it was easier to implement and didn't require changes in Onyx.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, I'll give it a thought and get back tomorrow

@sumo-slonik sumo-slonik changed the title Feature/kuba nowakowski/add empty state to expense view [DRAFT] Feature/kuba nowakowski/add empty state to expense view Mar 20, 2025
@mountiny mountiny requested a review from allgandalf March 20, 2025 15:24
Copy link
Contributor

@jnowakow jnowakow left a comment

Choose a reason for hiding this comment

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

Looks nice but I left some minor comments

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.

few comments, please address these

@@ -199,6 +199,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN;

const filteredTransactions = transactions?.filter((t) => t) ?? [];
const isEmpty = filteredTransactions.length === 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

areFilteredTransactionsEmpty ? 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.

If there are no transactions, it's a good indicator that we should display the empty state. This is possible right after creating reports.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool thanks !

Copy link
Contributor

Choose a reason for hiding this comment

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

actually no @mountiny need your input here we use isEmpty below:

Screenshot 2025-03-24 at 11 17 46 PM

It doesn't affect logic but the name doesn't ring a bell to me what is empty , should we change it or keep it as is

Copy link
Contributor

Choose a reason for hiding this comment

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

hasNoTransactions might be more explicit

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe following our guidelines to not negate variable names, it should be !hasTransactions

@@ -346,6 +346,9 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
if (hasScanningReceipt) {
return {icon: getStatusIcon(Expensicons.ReceiptScan), description: translate('iou.receiptScanInProgressDescription')};
}
if (isEmpty) {
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, I'll give it a thought and get back tomorrow

@@ -218,7 +212,8 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT
isCreateMenuActive && (!shouldUseNarrowLayout || isFocused),
);

const groupPoliciesWithChatEnabled = useMemo(() => getGroupPaidPoliciesWithExpenseChatEnabled(allPolicies as OnyxCollection<OnyxTypes.Policy>), [allPolicies]);
const paidGroupPolicies = useMemo(() => Object.values((allPolicies as OnyxCollection<OnyxTypes.Policy>) ?? {}).filter((policy) => isPaidGroupPolicy(policy)), [allPolicies]);
Copy link
Contributor

Choose a reason for hiding this comment

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

i think we have a util already present to check this one, can you use that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which utility are you referring to? Could you point me to the specific one?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this what you want:

App/src/libs/PolicyUtils.ts

Lines 436 to 438 in 79dcb22

function getOwnedPaidPolicies(policies: OnyxCollection<Policy> | null, currentUserAccountID: number): Policy[] {
return Object.values(policies ?? {}).filter((policy): policy is Policy => isPolicyOwner(policy, currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID) && isPaidGroupPolicy(policy));
}

@allgandalf
Copy link
Contributor

@sumo-slonik this branch has conflicts, can those be fixed please

@sumo-slonik sumo-slonik changed the title [DRAFT] Feature/kuba nowakowski/add empty state to expense view Feature/kuba nowakowski/add empty state to expense view Mar 21, 2025
…xpense-View

# Conflicts:
#	src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx
@sumo-slonik sumo-slonik marked this pull request as ready for review March 21, 2025 15:01
@sumo-slonik sumo-slonik requested review from a team as code owners March 21, 2025 15:01
@melvin-bot melvin-bot bot requested review from DylanDylann and removed request for a team March 21, 2025 15:01
Copy link

melvin-bot bot commented Mar 21, 2025

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

@trjExpensify trjExpensify removed the request for review from DylanDylann March 21, 2025 16:26
@shawnborton
Copy link
Contributor

One thing I'm not sure if we covered - there should be a way to delete the report directly from the details view, right? Not sure if we need to consider it in this or not, but just wanted to flag it cc @mountiny @trjExpensify
CleanShot 2025-03-28 at 10 53 40@2x

@shawnborton
Copy link
Contributor

Just calling this out for the @Expensify/design team - we have an orphan of "expenses" dangling on the second line but I don't feel like it's so bad we need to fix it since the word itself is wide:
CleanShot 2025-03-28 at 11 21 59@2x

Any strong thoughts?

@shawnborton
Copy link
Contributor

Otherwise this is feeling really good to me, nice work!

@sumo-slonik
Copy link
Contributor Author

Just calling this out for the @Expensify/design team - we have an orphan of "expenses" dangling on the second line but I don't feel like it's so bad we need to fix it since the word itself is wide:

if you think it needs to be changed then I will look into it, if not I guess that means we can merge?

@shawnborton
Copy link
Contributor

Yeah, it's something we could easily do as a follow up so we don't need to block on it for merge.

@allgandalf
Copy link
Contributor

Bug: There should be option to create workspace is not workspace exist:

@shawnborton to confirm, alternative is we should not show create report option if no workspace if present

Screen.Recording.2025-03-28.at.4.13.03.PM.mov

@allgandalf
Copy link
Contributor

allgandalf commented Mar 28, 2025

Bug: If we are opening i report then i would expect the Expense Report tab to get highlighted in the LHN, @mountiny @trjExpensify gut check please

Screen.Recording.2025-03-28.at.4.14.52.PM.mov

@allgandalf
Copy link
Contributor

allgandalf commented Mar 28, 2025

Bug: No option to add expense if report is created offline:
(I think this can be done in a follow up PR)

Screen.Recording.2025-03-28.at.4.16.47.PM.mov

@allgandalf
Copy link
Contributor

Bug?: We should have option to Create Report in the workspace chat + icon too right ? @trjExpensify @shawnborton ?

Screen.Recording.2025-03-28.at.4.18.24.PM.mov

@shawnborton
Copy link
Contributor

Good catch, I agree we should be able to create a report from the workspace chat.

@allgandalf
Copy link
Contributor

allgandalf commented Mar 28, 2025

Looking at the mocks, I expect the empty view to also open on the chat screen LHN:

Screenshot 2025-03-28 at 4 24 42 PM

But it only opens up on the reports page:

Screenshot 2025-03-28 at 4 26 33 PM

How do i open the empty view in the chats page?

Are the mocks outdated? or am i not aware of the latest conversation 😅

@mountiny
Copy link
Contributor

mountiny commented Mar 28, 2025

How do i open the empty view in the chats page?

this was agreed to be handled in future once the views are ready we will incorporate them to the Inbox page too

@sumo-slonik
Copy link
Contributor Author

I agree with @allgandalf comments, but I'm not sure they are related to the empty state itself, when it comes to creating reports and expensives it's probably a separate issue

@trjExpensify
Copy link
Contributor

trjExpensify commented Mar 28, 2025

Bug: If we are opening i report then i would expect the Expense Report tab to get highlighted in the LHN, @mountiny @trjExpensify gut check please

Fixed in this PR #58903 (comment)

Bug: No option to add expense if report is created offline:
(I think this can be done in a follow up PR)

Agreed, you should be able to do that offline. Can be taken care in a follow-up.

Bug?: We should have option to Create Report in the workspace chat + icon too right ? @trjExpensify @shawnborton ?

Yes you should, and opened in the Inbox when you take that action. I agree with Vit to handle that when the views are ready for the Inbox page.

Bug: There should be option to create workspace is not workspace exist:

@shawnborton to confirm, alternative is we should not show create report option if no workspace if present

Create report should only be shown if you're a member of a group workspace. CC: @SzymczakJ

@sumo-slonik
Copy link
Contributor Author

So if I understand correctly, all the bugs can be handled as a follow-up in the next PRs?

@allgandalf
Copy link
Contributor

YESS!!!!, Gimmme 5 to approve this one

@sumo-slonik
Copy link
Contributor Author

yeeeeah 🚀

@mountiny
Copy link
Contributor

all the bugs can be handled as a follow-up in the next PRs?

Could @allgandalf List them all so we can put it into one issue and then also let QA know to check that before creating a new ones?

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.

Thanks for all the hard work in this one @sumo-slonik ❤️ , looks good to get this one shipped


Here's the list of bugs:

  • There is option to Create Report in FAB when no workspaces are present
  • No create report option in workspace chat
  • New expenses added from the report view page doesn't get updated in the table of the report view.
  • No option to add expense if report is created offline
  • Expense tab is highlighted when report is opened in the search page

@mountiny feel free to create the tracking issue

@melvin-bot melvin-bot bot requested a review from mountiny March 28, 2025 11:41
@sumo-slonik
Copy link
Contributor Author

thanks for the review 🤗

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.

One comment left and added those follow ups here #59295

@@ -229,7 +235,7 @@ function buildNextStep(report: OnyxEntry<Report>, predictedNextStatus: ValueOf<t
};

// Scheduled submit enabled
if (harvesting?.enabled && autoReportingFrequency !== CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL) {
if (harvesting?.enabled && autoReportingFrequency !== CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL && isReportContainingTransactions) {
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 add test for NextStepsUtils for this - added here #59295

@mountiny
Copy link
Contributor

Since carlos already approved, and design has done a thorough review, I am going to merge this one

@mountiny mountiny merged commit 6f51252 into Expensify:main Mar 28, 2025
18 checks passed
@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.

Copy link
Contributor

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

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

Copy link
Contributor

github-actions bot commented Apr 1, 2025

🚀 Deployed to production by https://github.com/grgia in version: 9.1.21-3 🚀

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.