Skip to content
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

[Due for payment 2025-03-05] [$250] Track expense - Wrong position of the "New Message" line when track expense offline #55560

Open
2 of 8 tasks
vincdargento opened this issue Jan 21, 2025 · 25 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Overdue

Comments

@vincdargento
Copy link

vincdargento commented Jan 21, 2025

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.88-4
Reproducible in staging?: Yes
Reproducible in production?: Yes
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): N/A
Issue reported by: Applause Internal Team
Device used: Mac 15.2
App Component: Chat Report View

Action Performed:

  1. Open the app or navigate to https://staging.new.expensify.com
  2. Track expense in the Self DM
  3. Click Categorize it in the actionable whisper and finish the flow to move the expense to the workspace chat
  4. Navigate to Self DM
  5. Disable the connection
  6. Create a new track expense

Expected Result:

The "New Message" line is displayed above the created track expense and actionable whisper menu while offline or no "New Message" marker appears

Actual Result:

The "New Message" line is displayed under the created track expense while offline

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/~021884333549452358300
  • Upwork Job ID: 1884333549452358300
  • Last Price Increase: 2025-02-04
  • Automatic offers:
    • rayane-d | Reviewer | 106062960
Issue OwnerCurrent Issue Owner: @slafortune
@vincdargento vincdargento added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Jan 21, 2025
Copy link

melvin-bot bot commented Jan 21, 2025

Triggered auto assignment to @slafortune (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.

@M00rish
Copy link
Contributor

M00rish commented Jan 21, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-01-21 22:01:06 UTC.

Proposal

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

Track expense - Wrong position of the "New Message" line when track expense offline

What is the root cause of that problem?

logic is not couting for offline case

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

add check for offline :

{shouldDisplayNewMarker && (!shouldUseThreadDividerLine || !isFirstVisibleReportAction) && <UnreadActionIndicator reportActionID={action.reportActionID} />}

{!isOffline && shouldDisplayNewMarker && (!shouldUseThreadDividerLine || !isFirstVisibleReportAction) && <UnreadActionIndicator reportActionID={action.reportActionID} />}

or don't show UnreadActionIndicator for ACTIONABLETRACKEXPENSEWHISPER

{action.actionName !== CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_TRACK_EXPENSE_WHISPER && shouldDisplayNewMarker  .....

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

UI issue

What alternative solutions did you explore? (Optional)

another solution is filter out whisper actions in reportActionsList :

    const sortedwithoutWhisperReportActions = useMemo(() => {
    return sortedVisibleReportActions.filter(
        (reportAction) => reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_TRACK_EXPENSE_WHISPER
    );
}, [sortedVisibleReportActions]); 

    const prevsortedwithoutWhisperReportActions = usePrevious(sortedwithoutWhisperReportActions);

and replace them here :

const unreadMarkerReportActionID = useMemo(() => {

Image

@bernhardoj
Copy link
Contributor

bernhardoj commented Jan 22, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-01-22 03:01:37 UTC.

Proposal

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

The new message marker position is shown on the track expense actionable whisper.

What is the root cause of that problem?

The actionable whisper is detected as a message that is received while the user is offline.

// If the current message is the earliest message received while offline, we want to display the unread marker above this message.
const isEarliestReceivedOfflineMessage = index === earliestReceivedOfflineMessageIndex;
if (isEarliestReceivedOfflineMessage && !isNextMessageUnread) {
return true;
}

This is the logic to decide whether the message is received while offline or not.

const wasMessageReceivedWhileOffline = useCallback(
(message: OnyxTypes.ReportAction) =>
!wasActionTakenByCurrentUser(message) && wasActionCreatedWhileOffline(message, isOffline, lastOfflineAt.current, lastOnlineAt.current, preferredLocale),
[isOffline, lastOfflineAt, lastOnlineAt, preferredLocale],
);

function wasActionCreatedWhileOffline(action: ReportAction, isOffline: boolean, lastOfflineAt: Date | undefined, lastOnlineAt: Date | undefined, locale: Locale): boolean {
// The user was never online.
if (!lastOnlineAt) {
return true;
}
// The user never was never offline.
if (!lastOfflineAt) {
return false;
}
const actionCreatedAt = DateUtils.getLocalDateFromDatetime(locale, action.created);
// The action was created before the user went offline.
if (actionCreatedAt <= lastOfflineAt) {
return false;
}
// The action was created while the user was offline.
if (isOffline || actionCreatedAt < lastOnlineAt) {
return true;
}
// The action was created after the user went back online.
return false;
}

The logic was added in #49480 to show a new message marker when the user receives a message from another user/actor while offline. In our case, the actor of the actionable whisper is concierge. The problem is, in wasActionCreatedWhileOffline, if the app is currently offline, then the message is marked as received while offline.

const actionCreatedAt = DateUtils.getLocalDateFromDatetime(locale, action.created);
// The action was created before the user went offline.
if (actionCreatedAt <= lastOfflineAt) {
return false;
}
// The action was created while the user was offline.
if (isOffline || actionCreatedAt < lastOnlineAt) {
return true;
}

Based on the logic above, this can only happens if an optimistic action was added while the user is offline.

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

I don't think we want to mark an optimistic action as unread even when it's not from the current user, so I suggest to remove the isOffline check from wasActionCreatedWhileOffline.

// The action was created while the user was offline.
if (isOffline || actionCreatedAt < lastOnlineAt) {
return true;
}

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

We can add a new test to UnreadIndicatorsTest to make sure there is no unread marker line when tracking an expense.

@melvin-bot melvin-bot bot added the Overdue label Jan 24, 2025
Copy link

melvin-bot bot commented Jan 27, 2025

@slafortune Eep! 4 days overdue now. Issues have feelings too...

@slafortune slafortune added the External Added to denote the issue can be worked on by a contributor label Jan 28, 2025
Copy link

melvin-bot bot commented Jan 28, 2025

Job added to Upwork: https://www.upwork.com/jobs/~021884333549452358300

@melvin-bot melvin-bot bot changed the title Track expense - Wrong position of the "New Message" line when track expense offline [$250] Track expense - Wrong position of the "New Message" line when track expense offline Jan 28, 2025
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 28, 2025
Copy link

melvin-bot bot commented Jan 28, 2025

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

Copy link

melvin-bot bot commented Feb 3, 2025

@slafortune, @rayane-djouah Eep! 4 days overdue now. Issues have feelings too...

@melvin-bot melvin-bot bot added the Overdue label Feb 3, 2025
@rayane-d
Copy link
Contributor

rayane-d commented Feb 3, 2025

Sorry for the delay; I was sick at the end of last week. I'll review the issue today.

@melvin-bot melvin-bot bot removed the Overdue label Feb 3, 2025
Copy link

melvin-bot bot commented Feb 4, 2025

@slafortune @rayane-d this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

Copy link

melvin-bot bot commented Feb 4, 2025

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

@rayane-d
Copy link
Contributor

rayane-d commented Feb 4, 2025

Update: Reviewing past discussions in this related issue #44007 and PR #49480

@dylanexpensify
Copy link
Contributor

ty @rayane-d! Let's try and get next steps actioned today/tomorrow at latest!

@dylanexpensify dylanexpensify moved this to Bugs and Follow Up Issues in [#whatsnext] #expense Feb 4, 2025
@rayane-d
Copy link
Contributor

rayane-d commented Feb 4, 2025

I think the expected behavior is to not display the new message line at all in offline mode, consistent with the behavior in online mode (where no "New Message" marker appears).

@rayane-d
Copy link
Contributor

rayane-d commented Feb 4, 2025

@bernhardoj's proposal looks good to me

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Feb 4, 2025

Triggered auto assignment to @lakchote, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@rayane-d
Copy link
Contributor

rayane-d commented Feb 6, 2025

kind bump @lakchote

Copy link

melvin-bot bot commented Feb 10, 2025

@slafortune, @lakchote, @rayane-d Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot added the Overdue label Feb 10, 2025
@lakchote
Copy link
Contributor

@bernhardoj's proposal LGTM

@melvin-bot melvin-bot bot removed the Overdue label Feb 10, 2025
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Feb 10, 2025
Copy link

melvin-bot bot commented Feb 10, 2025

📣 @rayane-d 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@bernhardoj
Copy link
Contributor

PR is ready

cc: @rayane-d

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Feb 26, 2025
@melvin-bot melvin-bot bot changed the title [$250] Track expense - Wrong position of the "New Message" line when track expense offline [Due for payment 2025-03-05] [$250] Track expense - Wrong position of the "New Message" line when track expense offline Feb 26, 2025
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Feb 26, 2025
Copy link

melvin-bot bot commented Feb 26, 2025

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Feb 26, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.5-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2025-03-05. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Feb 26, 2025

@rayane-d @slafortune @rayane-d 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]

@rayane-d
Copy link
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/49480/files#r1972342424

  • [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:

  • N/A

Test:

  1. Open a self DM
  2. Turn off internet connection
  3. Create a new track expense
  4. Verify there is no new message unread marker line

Do we agree 👍 or 👎

@rayane-d
Copy link
Contributor

rayane-d commented Mar 2, 2025

I will request on NewDot once the summary is posted

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Overdue
Projects
Status: Bugs and Follow Up Issues
Development

No branches or pull requests

7 participants