Skip to content

[$250] App does not update message timestamps immediately after changing device timezone #68715

Closed

Description

@jponikarchuk

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.1.96-1
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: #68001
Email or phone of affected tester (no customers): applausetester+dp312@applause.expensifail.com
Issue reported by: Applause Internal Team
Device used: Mac / Safari
App Component: Other

Action Performed:

  1. Set device time to Automatic.
  2. Open the app and send a message. Observe the timestamp (matches device settings).
  3. Change device time to Manual and set a different timezone (e.g., Madrid).
  4. Return to the app.
  5. Observe the timestamp of previously sent messages.
  6. Send a new message in the same chat.
  7. Send a new message in another chat.
  8. Observe timestamps of new messages.
  9. Refresh the page/app.

Expected Result:

Timestamps should update to reflect the new device timezone immediately (both for old and new messages), without requiring a manual refresh.

Actual Result:

Old messages keep the previous timezone until the app is refreshed.
New messages also display the old timezone until refresh.
After refreshing, timestamps update correctly.

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

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021957689789412016624
  • Upwork Job ID: 1957689789412016624
  • Last Price Increase: 2025-09-16
Issue OwnerCurrent Issue Owner: @jliexpensify

Activity

  1. added
    Daily
    Bug
    on Aug 19, 2025
  2. melvin-bot commented on Aug 19, 2025

    @melvin-bot

    Triggered auto assignment to @jliexpensify (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. added
    External
    on Aug 19, 2025
  4. changed the title [-]App does not update message timestamps immediately after changing device timezone[/-] [+][$250] App does not update message timestamps immediately after changing device timezone[/+] on Aug 19, 2025
  5. melvin-bot commented on Aug 19, 2025

    @melvin-bot
  6. added
    Help Wanted
    on Aug 19, 2025
  7. melvin-bot commented on Aug 19, 2025

    @melvin-bot

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

  8. nabi-ebrahimi commented on Aug 19, 2025

    @nabi-ebrahimi
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-08-19 07:15:40 UTC.

    Proposal

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

    App does not update message timestamps immediately after changing device timezone

    What is the root cause of that problem?

    We only update the selected timestamp on page refresh.

    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) {
    PersonalDetails.updateAutomaticTimezone({
    automatic: true,
    selected: currentTimezone,
    });
    }
    },
    });

    Then we don't subscribe to device timezone changes when it is set to automatic.

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

    We can subscribe to the device's timezone and update the selected timezone in personalDetailsList in Onyx when it is set to automatic.

    import * as RNLocalize from "react-native-localize";
    
    
    const personalDetails = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {canBeMissing: true, selector: (value) => value?.[currentAccountID]});
    
    
      const handleChange = useCallback(() => {
            const currentTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone as SelectedTimezone;
            const prevTimezone = personalDetails?.[0]?.timezone;
    
            if (!isEmptyObject(currentTimezone) && prevTimezone?.automatic && prevTimezone?.selected !== currentTimezone) {
                PersonalDetails.updateAutomaticTimezone({
                    automatic: true,
                    selected: currentTimezone,
                });
            }
        }, [personalDetails]);
    
        useEffect(() => {
            if (Platform.OS === 'web') {
                document.addEventListener('visibilitychange', handleChange);
                window.addEventListener('focus', handleChange);
    
                return () => {
                    document.removeEventListener('visibilitychange', handleChange);
                    window.removeEventListener('focus', handleChange);
                };
            }
    
            RNLocalize.addEventListener('change', handleChange);
    
            return () => {
                RNLocalize.removeEventListener('change', handleChange);
            };
        }, [handleChange]);

    On the web, react-native-localize does not work. We can check the timezone on App Focus/Resume

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

    None

    What alternative solutions did you explore? (Optional)

    Instead of react-native-localize, we can listen to app state change and update the timezone if needed.

  9. dominictb commented on Aug 19, 2025

    @dominictb
    Contributor

    @nabi-ebrahimi Can you elaborate the web case and share a test branch? I don't like the periodical check idea.

  10. nabi-ebrahimi commented on Aug 19, 2025

    @nabi-ebrahimi
    Contributor

    @dominictb thanks for the review, this is the test branch

  11. ben-mathu commented on Aug 19, 2025

    @ben-mathu

    Proposal

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

    App does not update message timestamps immediately after changing device timezone

    What is the root cause of that problem?

    I believe the root cause is that the app does not listen to onFocus changes.
    The only registered events are mousemove, touchstart, keydown, scroll

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

    My proposal is to add visibilitychange event listener to the update date handler. It is supported by all the browsers as you can see from this link.

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

    Write tests to avoid regression. These test would check if the visibilitychange event is triggered and change in timezone changes the app time in realtime.

    What alternative solutions did you explore? (Optional)

    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.

  12. dominictb commented on Aug 22, 2025

    @dominictb
    Contributor

    This is a pretty niche bug. IMO, checking and setting timezone on app start alone is enough. A normal user would rarely change the timezone their own. But if we still want to fix this, we could go with @nabi-ebrahimi proposal.

    Note for @nabi-ebrahimi:

    • We don't need window's focus event.
    • Use Visibility.onVisibilityChange instead
    • Use early return
    • Create platform-specific files for this logic

    C+ reviewed 🎀👀🎀

  13. 15 remaining items

  14. melvin-bot commented on Sep 2, 2025

    @melvin-bot

    @jliexpensify Still overdue 6 days?! Let's take care of this!

  15. melvin-bot commented on Sep 9, 2025

    @melvin-bot

    📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

  16. melvin-bot commented on Sep 9, 2025

    @melvin-bot

    @jliexpensify 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

  17. jliexpensify commented on Sep 9, 2025

    @jliexpensify
    Contributor

    @neil-marcellini should we close this if it's not worth fixing?

  18. melvin-bot commented on Sep 12, 2025

    @melvin-bot

    @jliexpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!

  19. jliexpensify commented on Sep 14, 2025

    @jliexpensify
    Contributor

    Bump @neil-marcellini can we close this?

  20. melvin-bot commented on Sep 16, 2025

    @melvin-bot

    📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

  21. melvin-bot commented on Sep 16, 2025

    @melvin-bot

    @neil-marcellini @jliexpensify @dominictb this issue is now 4 weeks old, please consider:

    • Finding a contributor to fix the bug
    • Closing the issue if BZ has been unable to add the issue to a VIP or Wave project
    • If you have any questions, don't hesitate to start a discussion in #expensify-open-source

    Thanks!

  22. jliexpensify commented on Sep 16, 2025

    @jliexpensify
    Contributor

    Chatted to Neil via DM's, lets close this.

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

Metadata

Metadata

Labels

BugDailyExternalHelp Wanted

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions