Skip to content

[Hold for payment 2024-12-25][$250] Timezone is not updated to the messages sent #52975

Closed

Description

@m-natarajan

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:
Reproducible in staging?: needs reproduction
Reproducible in production?: needs reproduction
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?:
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @neil-marcellini
Slack conversation (hyperlinked to channel name): expensify - bugs

Action Performed:

  1. Set your timezone automatically
  2. Send a message and note the time is displayed properly
  3. Travel to a new timezone
  4. Verify your timezone shows that it has updated in Settings > Profile
  5. Send another message

Expected Result:

The created time is shown in the user's updated current timezone

Actual Result:

The created time is shown in the user's previous timezone

Workaround:

unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

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

Screenshots/Videos

Add any screenshot/video evidence
https://app.screencast.com/LHXPoXQVOgFgJ [View all open jobs on GitHub](https://github.com/Expensify/App/issues?q=is%3Aopen+is%3Aissue+label%3A%22Help+Wanted%22)
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021860030469423904950
  • Upwork Job ID: 1860030469423904950
  • Last Price Increase: 2024-11-29
Issue OwnerCurrent Issue Owner: @sonialiap

Activity

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

    @melvin-bot

    Triggered auto assignment to @sonialiap (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. MelvinBot commented on Nov 22, 2024

    @MelvinBot
    Contributor

    This has been labelled "Needs Reproduction". Follow the steps here: https://stackoverflowteams.com/c/expensify/questions/16989

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Nov 22, 2024
  5. changed the title [-]Timezone is not updated to the messages sent[/-] [+][$250] Timezone is not updated to the messages sent[/+] on Nov 22, 2024
  6. melvin-bot commented on Nov 22, 2024

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

    @melvin-bot

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

  9. neil-marcellini commented on Nov 22, 2024

    @neil-marcellini
    Contributor

    I can help with this one on the internal engineering side. First we need to figure out how to reproduce it. Is there a way we can mess with the networks settings to make the computer think it has changed timezones? Probably. @getusha could you please try to reproduce that way?

  10. bernhardoj commented on Nov 23, 2024

    @bernhardoj
    Contributor

    Proposal

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

    The timezone is not updated.

    What is the root cause of that problem?

    I can repro this with the following steps:

    1. Send a message in timezone A. The message timestamp shows in timezone A
    2. Change my device timezone to B
    3. Go to settings and refresh, it shows the timezone B
    4. Go back to chat, the message timestamp is still in timezone A
    5. Send a new message
    6. The message timestamp is still in timezone A

    On the step 3, this logic will be executed.

    Onyx.connect({
    key: ONYXKEYS.PERSONAL_DETAILS_LIST,
    callback: (value) => {
    if (!value || !isEmptyObject(timezone)) {
    return;
    }
    timezone = value?.[currentAccountID]?.timezone ?? {};
    const currentTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone as SelectedTimezone;
    // If the current timezone is different than the user's timezone, and their timezone is set to automatic
    // then update their timezone.
    if (!isEmptyObject(currentTimezone) && timezone?.automatic && timezone?.selected !== currentTimezone) {
    timezone.selected = currentTimezone;
    PersonalDetails.updateAutomaticTimezone({
    automatic: true,
    selected: currentTimezone,
    });

    It compares the user saved timezone with the current timezone of the device. If it's different, then it updates the timezone. However, it doesn't work correctly. In updateAutomaticTimezone, we already optimistically update the timezone, but it's never applied.

    API.write(WRITE_COMMANDS.UPDATE_AUTOMATIC_TIMEZONE, parameters, {
    optimisticData: [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: ONYXKEYS.PERSONAL_DETAILS_LIST,
    value: {
    [currentUserAccountID]: {
    timezone: formatedTimezone,
    },
    },

    It's because onyx detected that there is nothing to change. Why? It's because before we update the onyx, we mutate the object of the timezone.

    timezone.selected = currentTimezone;
    PersonalDetails.updateAutomaticTimezone({
    automatic: true,
    selected: currentTimezone,
    });

    We also have a logic to update the timezone when adding an action, but since we mutate the timezone object, the onyx storage is never updated.

    // Update the timezone if it's been 5 minutes from the last time the user added a comment
    if (DateUtils.canUpdateTimezone() && currentUserAccountID) {
    const timezone = DateUtils.getCurrentTimezone();
    parameters.timezone = JSON.stringify(timezone);
    optimisticData.push({
    onyxMethod: Onyx.METHOD.MERGE,
    key: ONYXKEYS.PERSONAL_DETAILS_LIST,
    value: {[currentUserAccountID]: {timezone}},
    });
    DateUtils.setTimezoneUpdated();
    }

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

    Don't mutate the timezone object here.

    timezone.selected = currentTimezone;
    PersonalDetails.updateAutomaticTimezone({
    automatic: true,
    selected: currentTimezone,
    });

    We already update the timezone optimistically inside updateAutomaticTimezone. But if we still need to update the timezone object immediately, we need to clone the timezone object here.

    timezone = value?.[currentAccountID]?.timezone ?? {};

  11. 45 remaining items

  12. melvin-bot commented on Jan 24, 2025

    @melvin-bot

    @sonialiap, @neil-marcellini, @bernhardoj, @getusha Whoops! This issue is 2 days overdue. Let's get this updated quick!

  13. sonialiap commented on Jan 24, 2025

    @sonialiap
    Contributor

    🙈 automation didn't run, making payments now

  14. sonialiap commented on Jan 24, 2025

    @sonialiap
    Contributor

    Payment summary:
    @bernhardoj $250 please request in ND
    @getusha $250 please request in ND - as the C+ could you please complete the checklist? Sharing the template below 👇

    Checklist, click to unfurl
    # BugZero Checklist:
    
    - [ ] **[Contributor]** Classify the bug:
    
    <details>
    <summary>Bug classification</summary>
    <!-- Please keep the "1a." text in tact on all of the options below so that the results can be easily parsed by a script. Each of the "Other" options should be last on the list which is why they have a "z" in the selector (eg. "1z."). This allows the list to grow if someone desires to add more options down the road. -->
    
    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:
    
    </details>
    
    - [ ] **[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:
    
    - [ ] **[Contributor]** If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in [#expensify-open-source](https://app.slack.com/client/E047TPA624F/C01GTK53T8Q) 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:
    
    - [ ] **[Contributor]** If it was decided to create a regression test for the bug, please propose the [regression test](https://github.com/Expensify/App/blob/main/contributingGuides/REGRESSION_TEST_BEST_PRACTICES.md) steps using the template below to ensure the same bug will not reach production again.
    
    <details>
    <summary>Regression Test Proposal Template</summary>
    <!-- AFTER FILLING THIS OUT, be sure to remove the <details> and <summary> tags from this part of the checklist!!!!! -->
    
    - [ ] **[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:
    <!-- List the setup instructions necessary to perform the test -->
    
    -
    
    ### Test:
    <!-- List the steps that QA should perform -->
    
    1.
    
    Do we agree 👍 or 👎
    
    <!-- AFTER FILLING THIS OUT, be sure to remove the <details> tags!!!!! -->
    </details>
    
  15. changed the title [-][$250] Timezone is not updated to the messages sent[/-] [+][Hold for payment 2024-12-25][$250] Timezone is not updated to the messages sent[/+] on Jan 24, 2025
  16. bernhardoj commented on Jan 24, 2025

    @bernhardoj
    Contributor

    Requested in ND.

  17. getusha commented on Jan 27, 2025

    @getusha
    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/28307/files#r1930871527

    • [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: https://github.com/Expensify/Expensify/issues/465177

    Regression Test Proposal

    Test:

    1. Send a message in timezone A
    2. Change the device timezone to B
    3. Go to settings and refresh (or reopen the app for Android & iOS)
    4. Verify it shows the timezone B
    5. Send a new message in a different chat
    6. Verify the message timestamp is in timezone B

    Do we agree 👍 or 👎

  18. melvin-bot commented on Jan 28, 2025

    @melvin-bot

    @sonialiap, @neil-marcellini, @bernhardoj, @getusha Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  19. JmillsExpensify commented on Jan 29, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @bernhardoj

  20. garrettmknight commented on Jan 29, 2025

    @garrettmknight
    Contributor

    $250 approved for @getusha

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 productionDailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions