Skip to content

[HOLD for payment 2025-01-30] [$250] Invoice - "Hidden" name shown when creating invoice for non existing user #54211

Closed

Description

@vincdargento

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v9.0.76-6
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): testpayment935+796@gmail.com
Issue reported by: Applause Internal Team
Device used: Windows 10 / Chrome
App Component: Other

Action Performed:

  1. Navigate to https://staging.new.expensify.com
  2. Create WS> more features> enable invoice
  3. Navigate to FAB> Send invoice
  4. Enter amount and insert non existing user and finish the flow
  5. Navigate to invoice detail and navigate back

Expected Result:

After creating the invoice, The user name should be the email as the account is non existing

Actual Result:

The user name shows "Hidden" at first
After navigating to the invoice and go back, the "Hidden" changed to random user name

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

bug.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021869525665327494178
  • Upwork Job ID: 1869525665327494178
  • Last Price Increase: 2025-01-01
Issue OwnerCurrent Issue Owner: @twisterdotcom

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Dec 16, 2024
  2. melvin-bot commented on Dec 16, 2024

    @melvin-bot

    Triggered auto assignment to @twisterdotcom (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. bernhardoj commented on Dec 17, 2024

    @bernhardoj
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Hidden user is shown when sending an invoice to a user we never chatted before.

    What is the root cause of that problem?

    I can't fully reproduce the issue. In my testing, the Hidden only shows on the header name. Based on the QA recording, looks like there is some BE problem too.

    When we send a new invoice to a user we never chatted before, we will optimistically create a new personal details for that user. Then, we get the invoice room name from the receiver account ID and the personal details list.

    App/src/libs/ReportUtils.ts

    Lines 3928 to 3930 in d86024e

    if (isIndividual) {
    return LocalePhoneNumber.formatPhoneNumber(PersonalDetailsUtils.getDisplayNameOrDefault(allPersonalDetails?.[invoiceReceiverAccountID]));
    }

    However, the issue happens when the header is rendered before the personal details list optimistic data is merged. The allPersonalDetails is coming from the lib Onyx.connect which won't trigger a re-render when the personal detail is updated.

    But actually, on the HeaderView, we already subscribed to the personal details list Onyx using useOnyx and passed it to getReportName, so whenever the personal details list is updated, the getReportName will be called again.

    const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);

    const title = ReportUtils.getReportName(reportHeaderData, policy, parentReportAction, personalDetails, invoiceReceiverPolicy);

    So, it should re-trigger getInvoicesChatName when the personal details are updated. However, the allPersonalDetails list here is updated later after the useOnyx hook.

    App/src/libs/ReportUtils.ts

    Lines 3928 to 3930 in d86024e

    if (isIndividual) {
    return LocalePhoneNumber.formatPhoneNumber(PersonalDetailsUtils.getDisplayNameOrDefault(allPersonalDetails?.[invoiceReceiverAccountID]));
    }

    So, even though the function is re-triggered, the allPersonalDetails still holds the old value.

    What changes do you think we should make in order to solve the problem?

    Pass the personal details from the component to getInvoicesChatName

    App/src/libs/ReportUtils.ts

    Lines 4084 to 4086 in d86024e

    if (isInvoiceRoom(report)) {
    formattedName = getInvoicesChatName(report, invoiceReceiverPolicy);
    }

    formattedName = getInvoicesChatName(report, invoiceReceiverPolicy, personalDetails);
    

    And use it here

    App/src/libs/ReportUtils.ts

    Lines 3916 to 3930 in d86024e

    function getInvoicesChatName(report: OnyxEntry<Report>, receiverPolicy: OnyxEntry<Policy>): string {
    const invoiceReceiver = report?.invoiceReceiver;
    const isIndividual = invoiceReceiver?.type === CONST.REPORT.INVOICE_RECEIVER_TYPE.INDIVIDUAL;
    const invoiceReceiverAccountID = isIndividual ? invoiceReceiver.accountID : -1;
    const invoiceReceiverPolicyID = isIndividual ? '' : invoiceReceiver?.policyID ?? '-1';
    const invoiceReceiverPolicy = receiverPolicy ?? getPolicy(invoiceReceiverPolicyID);
    const isCurrentUserReceiver = (isIndividual && invoiceReceiverAccountID === currentUserAccountID) || (!isIndividual && PolicyUtils.isPolicyAdmin(invoiceReceiverPolicy));
    if (isCurrentUserReceiver) {
    return getPolicyName(report);
    }
    if (isIndividual) {
    return LocalePhoneNumber.formatPhoneNumber(PersonalDetailsUtils.getDisplayNameOrDefault(allPersonalDetails?.[invoiceReceiverAccountID]));
    }

    if (isIndividual) {
        return LocalePhoneNumber.formatPhoneNumber(PersonalDetailsUtils.getDisplayNameOrDefault((personalDetails ?? allPersonalDetails)?.[invoiceReceiverAccountID]));
    }
    

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    This requires a UI test where we need to assert that the HeaderView of invoice room title is updated when the personal detail is updated.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Dec 18, 2024
  5. changed the title [-]Invoice - Random user name generates when creating invoice for non existing user[/-] [+][$250] Invoice - Random user name generates when creating invoice for non existing user[/+] on Dec 18, 2024
  6. melvin-bot commented on Dec 18, 2024

    @melvin-bot
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Dec 18, 2024
  8. melvin-bot commented on Dec 18, 2024

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @jjcoffee (External)

  9. changed the title [-][$250] Invoice - Random user name generates when creating invoice for non existing user[/-] [+][$250] Invoice - "Hidden" name shown when creating invoice for non existing user[/+] on Dec 18, 2024
  10. 35 remaining items

  11. melvin-bot commented on Jan 23, 2025

    @melvin-bot

    @jjcoffee @twisterdotcom @jjcoffee The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  12. changed the title [-][HOLD for payment 2025-01-30] [HOLD for payment 2025-01-28] [$250] Invoice - "Hidden" name shown when creating invoice for non existing user[/-] [+][HOLD for payment 2025-01-30] [$250] Invoice - "Hidden" name shown when creating invoice for non existing user[/+] on Jan 28, 2025
  13. twisterdotcom commented on Jan 29, 2025

    @twisterdotcom
    Contributor

    Waiting for tomorrow and also the BZ checklist.

  14. jjcoffee commented on Jan 29, 2025

    @jjcoffee
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: https://github.com/Expensify/App/pull/44970/files#r1934051853

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: N/A

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Precondition:

    • Have a workspace with invoices enabled

    Test:

    1. Send an invoice to a new user you have never chatted with before
    2. Verify the header and report preview doesn't show Hidden

    Do we agree 👍 or 👎

  15. melvin-bot commented on Jan 30, 2025

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@twisterdotcom)

    • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1869525665327494178/hired)
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  16. twisterdotcom commented on Jan 30, 2025

    @twisterdotcom
    Contributor

    Payment Summary:

  17. bernhardoj commented on Jan 30, 2025

    @bernhardoj
    Contributor

    Requested in ND.

  18. JmillsExpensify commented on Jan 31, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @bernhardoj

  19. garrettmknight commented on Feb 3, 2025

    @garrettmknight
    Contributor

    $250 approved for @jjcoffee

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions