Skip to content

Profile - "Address line 1" is shown instead of "Address line 2" #77159

Closed

Description

@nlemma

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: 9.2.74-1
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #76156
Email or phone of affected tester (no customers): jnsdonsoijnods@gmail.com
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Mac 26.1 / Chrome
App Component: User Settings

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to Account > Profile.
  3. Scroll down and click Address.

Expected Result:

"Address line 2" will be shown for the second address line field.

Actual Result:

"Address line 1" is shown instead of "Address line 2".

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug7025105_1765297366951.7.mp4

View all open jobs on GitHub

Activity

  1. added
    Daily
    Bug
    on Dec 9, 2025
  2. melvin-bot commented on Dec 9, 2025

    @melvin-bot

    Triggered auto assignment to @JmillsExpensify (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. daledah commented on Dec 9, 2025

    @daledah
    Contributor

    Proposal

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

    "Address line 1" is shown instead of "Address line 2".

    What is the root cause of that problem?

    We have error here

    addressLine: (lineNumber: number) => `Address line ${lineNumber}`,

    The translation function addressLine accepted a number directly, which conflicted with memoization when parameters weren’t objects.

    const memoizedGetTranslatedPhrase = memoize(getTranslatedPhrase, {
    maxArgs: 2,
    equality: 'shallow',
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    skipCache: (params) => !isEmptyObject(params.at(2)),
    });

    When calling:

    • translate('common.addressLine', 1) → cache key is [locale, 'common.addressLine']
    • translate('common.addressLine', 2) → cache key is [locale, 'common.addressLine']

    Both share the same cache key, so the second call returns the cached result from the first.

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

    We can update the skipCache in memoizedGetTranslatedPhrase function to

      skipCache: (params) => {
          const thirdParam = params.at(2);
          // Skip cache if there are parameters (even if they're primitives)
          return thirdParam !== undefined;
      },
    

    What alternative solutions did you explore? (Optional)

    Option 1: We should update it to

            addressLine: ({lineNumber}: {lineNumber: number}) => `Address line ${lineNumber}`,
    

    Then update all places that use addressLine translations to use object

    Option 2: Increase maxArgs to include parameters from 2 -> 3

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  4. added
    DeployBlockerCash
    on Dec 9, 2025
  5. melvin-bot commented on Dec 9, 2025

    @melvin-bot

    Triggered auto assignment to @tylerkaraszewski (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  6. melvin-bot commented on Dec 9, 2025

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  7. github-actions commented on Dec 9, 2025

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  8. Nodebrute commented on Dec 9, 2025

    @Nodebrute
    Contributor

    Proposal

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

    Address line 1" is shown instead of "Address line 2

    What is the root cause of that problem?

    The translation memoization in here incorrectly caches translations with number parameters.
    When translate('common.addressLine', 1) and translate('common.addressLine', 2) are called:
    Both share the same first two arguments (locale and path), so the memoization uses the same cache key.
    The skipCache function checks !isEmptyObject(params.at(2)), which returns false for numbers (since isEmptyObject(1) returns true).
    The cache is not skipped, so both calls return the same cached result from the first call ("Address line 1"). The skipCache logic was intended to skip cache only when parameters are non-empty objects (for pluralization), but it doesn't handle primitive parameters like numbers.

    skipCache: (params) => !isEmptyObject(params.at(2)),

    Why this was working previously?
    Because before we were doing things by passing object parameter translate('common.addressLine', {lineNumber: 1})

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

    We should skip cache when any parameters are provided not just non-empty objects. This ensures translations with number parameters don't share cache

        skipCache: (params) => params.length > 2,
    

    What alternative solutions did you explore? (Optional) Better solution

    Remove maxArgs: 2 and skipCache so all arguments are used in the cache key. Now:
    translate('common.addressLine', 1) → cache key: ['en', 'common.addressLine', 1]
    translate('common.addressLine', 2) → cache key: ['en', 'common.addressLine', 2]
    They are cached separately and return the correct values. This also fixes similar cases like translate('paymentMethodList.bankAccountLastFour', lastFour).

    const memoizedGetTranslatedPhrase = memoize(getTranslatedPhrase, {
    maxArgs: 2,
    equality: 'shallow',
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    skipCache: (params) => !isEmptyObject(params.at(2)),

    Why skipcache was added
    With maxArgs: 2, only locale and path were used for the cache key, ignoring parameters. That meant:
    translate('common.addressLine', {lineNumber: 1}) → cache key: ['en', 'common.addressLine']
    translate('common.addressLine', {lineNumber: 2}) → cache key: ['en', 'common.addressLine'] (same)
    To avoid wrong cached results, skipCache was added to bypass the cache when object parameters were present. This was a workaround, not a fix.

    Why remove skipCache
    It's unnecessary with the correct fix If we remove maxArgs: 2, all arguments including parameters are included in the cache key Different parameters get different cache entries automatically No need to skip the cache

  9. added
    Reviewing
    on Dec 10, 2025
  10. situchan commented on Dec 10, 2025

    @situchan
    Contributor

    Offending PR: #76721
    cc: @mrejdak @QichenZhu

  11. yuwenmemon commented on Dec 10, 2025

    @yuwenmemon
    Contributor

    Hmmm... I'd rather revert the culprit and have @mrejdak and @QichenZhu work on this again than try a patch fix. Going to revert instead. Sorry @daledah

  12. IuliiaHerets commented on Dec 10, 2025

    @IuliiaHerets

    Issue is not reproducible for QA team on Windows 11 / Chrome in v9.2.74-8

    bandicam.2025-12-10.14-49-51-549.mp4
  13. yuwenmemon commented on Dec 10, 2025

    @yuwenmemon
    Contributor

    Thanks!

  14. blazejkustra commented on Dec 10, 2025

    @blazejkustra
    Contributor

    @mrejdak is OOO today, he'll look into it tomorrow. Thank you for handling it @yuwenmemon 😄

  15. daledah commented on Dec 10, 2025

    @daledah
    Contributor

    @yuwenmemon @JmillsExpensify I was assigned to this issue and created the PR #77198. But then we decided to revert offending PR.

    100% due if contributor drafted a PR and requested a review.

    According to this comment #49931 (comment), I think I should be eligible for payment here.

  16. removed
    DeployBlockerCash
    on Dec 10, 2025
  17. JmillsExpensify commented on Dec 11, 2025

    @JmillsExpensify
    Contributor

    Yes, that's correct.

    Payment summary: $250 @daledah via Upwork.

  18. JmillsExpensify commented on Dec 11, 2025

    @JmillsExpensify
    Contributor

    Offer sent, please accept in Upwork

  19. daledah commented on Dec 12, 2025

    @daledah
    Contributor

    Thanks @JmillsExpensify, i accepted

  20. JmillsExpensify commented on Dec 12, 2025

    @JmillsExpensify
    Contributor

    Paid

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

Metadata

Metadata

Labels

BugEngineeringHourlyReviewing

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions