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

[HOLD for payment 2024-05-22] Hold expense - Thread header for system message is different from the actual system message #41202

Closed
6 tasks done
izarutskaya opened this issue Apr 29, 2024 · 27 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 Internal Requires API changes or must be handled by Expensify staff

Comments

@izarutskaya
Copy link

izarutskaya commented Apr 29, 2024

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: 1.4.67-0
Reproducible in staging?: Y
Reproducible in production?: Y
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: Applause-Internal team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Submit two expenses to a user.
  3. Go to transaction thread of any expense.
  4. Click 3-dot menu > Hold expense.
  5. Enter a reason and save it.
  6. Right click on the hold expense system message > Reply in thread.

Expected Result:

The thread header message will be consistent with the system message.

Actual Result:

The thread header shows "held this money request", while the system message is "held this expense".

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6464774_1714364776428.bandicam_2024-04-29_12-23-13-201.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01de18ac2a60287419
  • Upwork Job ID: 1786066158847115264
  • Last Price Increase: 2024-05-02
Issue OwnerCurrent Issue Owner: @miljakljajic
@izarutskaya izarutskaya added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Apr 29, 2024
Copy link

melvin-bot bot commented Apr 29, 2024

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

@izarutskaya
Copy link
Author

We think this issue might be related to the #collect project.

@dragnoir
Copy link
Contributor

BE issue.

@bernhardoj
Copy link
Contributor

Proposal

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

The thread header title for hold system message is different than the message.

What is the root cause of that problem?

For a thread, the header title will take the parent action message. The hold system message is "held this money request" as shown below
image

But when we render the hold system message, we render a custom message, that is "held this expense".

} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) {
children = <ReportActionItemBasicMessage message={translate('iou.heldExpense')} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD_COMMENT) {
children = <ReportActionItemBasicMessage message={action.message?.[0]?.text ?? ''} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) {
children = <ReportActionItemBasicMessage message={translate('iou.unheldExpense')} />;

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

We have 2 options,

First, in ReportUtils.getReportName, if it's a hold action, then we show the custom message ("held this expense").

App/src/libs/ReportUtils.ts

Lines 3057 to 3092 in e0c12a5

if (isChatThread(report)) {
if (!isEmptyObject(parentReportAction) && ReportActionsUtils.isTransactionThread(parentReportAction)) {
formattedName = getTransactionReportName(parentReportAction);
if (isArchivedRoom(report)) {
formattedName += ` (${Localize.translateLocal('common.archived')})`;
}
return formattedName;
}
if (parentReportAction?.message?.[0]?.isDeletedParentAction) {
return Localize.translateLocal('parentReportAction.deletedMessage');
}
const isAttachment = ReportActionsUtils.isReportActionAttachment(!isEmptyObject(parentReportAction) ? parentReportAction : null);
const parentReportActionMessage = getReportActionMessage(parentReportAction, report?.parentReportID).replace(/(\r\n|\n|\r)/gm, ' ');
if (isAttachment && parentReportActionMessage) {
return `[${Localize.translateLocal('common.attachment')}]`;
}
if (
parentReportAction?.message?.[0]?.moderationDecision?.decision === CONST.MODERATION.MODERATOR_DECISION_PENDING_HIDE ||
parentReportAction?.message?.[0]?.moderationDecision?.decision === CONST.MODERATION.MODERATOR_DECISION_HIDDEN ||
parentReportAction?.message?.[0]?.moderationDecision?.decision === CONST.MODERATION.MODERATOR_DECISION_PENDING_REMOVE
) {
return Localize.translateLocal('parentReportAction.hiddenMessage');
}
if (isAdminRoom(report) || isUserCreatedPolicyRoom(report)) {
return getAdminRoomInvitedParticipants(parentReportAction, parentReportActionMessage);
}
if (parentReportActionMessage && isArchivedRoom(report)) {
return `${parentReportActionMessage} (${Localize.translateLocal('common.archived')})`;
}
if (ReportActionsUtils.isModifiedExpenseAction(parentReportAction)) {
return ModifiedExpenseMessage.getForReportAction(report?.reportID, parentReportAction);
}
return parentReportActionMessage;
}

if (parentReportAction.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) {
    return Localize.translateLocal('iou.heldExpense')
}

OR

Show the original message of the hold action, just like what we did for HOLD_COMMENT.

} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) {
children = <ReportActionItemBasicMessage message={translate('iou.heldExpense')} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD_COMMENT) {
children = <ReportActionItemBasicMessage message={action.message?.[0]?.text ?? ''} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) {
children = <ReportActionItemBasicMessage message={translate('iou.unheldExpense')} />;

Depends on the team which message to use.

we need to fix for unhold action too

@melvin-bot melvin-bot bot added the Overdue label May 1, 2024
@miljakljajic miljakljajic added the Internal Requires API changes or must be handled by Expensify staff label May 2, 2024
Copy link

melvin-bot bot commented May 2, 2024

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

Copy link

melvin-bot bot commented May 2, 2024

Triggered auto assignment to Contributor Plus for review of internal employee PR - @Ollyws (Internal)

@melvin-bot melvin-bot bot removed the Overdue label May 2, 2024
@miljakljajic
Copy link
Contributor

Added the relevant labels

@melvin-bot melvin-bot bot added the Overdue label May 6, 2024
@Ollyws
Copy link
Contributor

Ollyws commented May 6, 2024

Seems that replying in thread has been disabled for the hold system message rendering this issue un-reproducable.

@melvin-bot melvin-bot bot removed the Overdue label May 6, 2024
@bernhardoj
Copy link
Contributor

It's not disabled because it's a system message, but because it's detected as a deleted action. A hold action has an empty text/html, so it's detected as a deleted action
image

I think we should make an exception for HOLD action

App/src/libs/ReportUtils.ts

Lines 6134 to 6136 in 942cad9

function shouldDisableThread(reportAction: OnyxEntry<ReportAction>, reportID: string): boolean {
const isSplitBillAction = ReportActionsUtils.isSplitBillAction(reportAction);
const isDeletedAction = ReportActionsUtils.isDeletedAction(reportAction);

or let BE return a text for HOLD action as we did optimistically.

App/src/libs/ReportUtils.ts

Lines 4427 to 4437 in 942cad9

function buildOptimisticHoldReportAction(created = DateUtils.getDBTime()): OptimisticHoldReportAction {
return {
reportActionID: NumberUtils.rand64(),
actionName: CONST.REPORT.ACTIONS.TYPE.HOLD,
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
actorAccountID: currentUserAccountID,
message: [
{
type: CONST.REPORT.MESSAGE.TYPE.TEXT,
style: 'normal',
text: Localize.translateLocal('iou.heldExpense'),

@Ollyws
Copy link
Contributor

Ollyws commented May 6, 2024

@bernhardoj Are you suggesting this was unintentional and that replying in threads should be enabled for the HOLD action?

@bernhardoj
Copy link
Contributor

yes

@Ollyws
Copy link
Contributor

Ollyws commented May 6, 2024

Yeah I agree we shouldn't be considering the HOLD message as a deleted request, and it's better that we use iou.heldExpense so they're congruent and also because the backend message will not translate to Spanish otherwise.

@bernhardoj's proposal LGTM.

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented May 6, 2024

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

@neil-marcellini
Copy link
Contributor

Yeah I agree we shouldn't be considering the HOLD message as a deleted request, and it's better that we use iou.heldExpense so they're congruent and also because the backend message will not translate to Spanish otherwise.

@bernhardoj's proposal LGTM.

🎀👀🎀 C+ reviewed

Sounds good to me. @bernhardoj if you would please update your original proposal with the fix for not considering HOLD messages as deleted, that would be good for people looking at the proposal in the future. I've heard that now we have a deleted key on deleted messages, so that might be an alternative. Please start on a PR.

@bernhardoj
Copy link
Contributor

PR is ready

I see that after we reload the page (retriggers the OpenReport), the BE returns the message for the HOLD/UNHOLD action, so I don't include the code to make an exception for HOLD/UNHOLD action in isDeletedAction code. I think we should fix the HoldRequest and UnHoldRequest requests to return the correct action message.

I've heard that now we have a deleted key on deleted messages, so that might be an alternative.

Yes, we already use it but we still check for the text and html of message as the legacy way.

// A legacy deleted comment has either an empty array or an object with html field with empty string as value
const isLegacyDeletedComment = message.length === 0 || message[0]?.html === '';
return isLegacyDeletedComment || !!message[0]?.deleted;

For legacy support, we're still hiding ADDCOMMENT actions that have an empty message.

Based on the PR comment that implements it, we want to use the legacy way for ADDCOMMENT action, so maybe we should start doing that (on a separate issue).

cc: @Ollyws @neil-marcellini

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels May 15, 2024
@melvin-bot melvin-bot bot changed the title Hold expense - Thread header for system message is different from the actual system message [HOLD for payment 2024-05-22] Hold expense - Thread header for system message is different from the actual system message May 15, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label May 15, 2024
Copy link

melvin-bot bot commented May 15, 2024

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

Copy link

melvin-bot bot commented May 15, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.73-7 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 2024-05-22. 🎊

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

  • @Ollyws requires payment (Needs manual offer from BZ)
  • @bernhardoj requires payment (Needs manual offer from BZ)

Copy link

melvin-bot bot commented May 15, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@Ollyws] The PR that introduced the bug has been identified. Link to the PR:
  • [@Ollyws] 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:
  • [@Ollyws] A discussion in #expensify-bugs 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:
  • [@Ollyws] Determine if we should create a regression test for this bug.
  • [@Ollyws] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@miljakljajic] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels May 21, 2024
Copy link

melvin-bot bot commented May 22, 2024

Payment Summary

Upwork Job

  • ROLE: @Ollyws paid $(AMOUNT) via Upwork (LINK)
  • ROLE: @bernhardoj paid $(AMOUNT) via Upwork (LINK)

BugZero Checklist (@miljakljajic)

  • 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/1786066158847115264/hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@miljakljajic
Copy link
Contributor

Contracts extended to you both!

@Ollyws
Copy link
Contributor

Ollyws commented May 22, 2024

Requested payment in ND for this one.

@Ollyws
Copy link
Contributor

Ollyws commented May 23, 2024

BugZero Checklist:

  • The PR that introduced the bug has been identified. Link to the PR:

#38884

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

#38884 (comment)

  • A discussion in #expensify-bugs 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

  • Determine if we should create a regression test for this bug.

Yes

  • If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.

Regression Test Proposal

1. Submit a new expense to anyone
2. Open the transaction thread and put it on hold
3. Unhold the expense
4. There is currently a BE bug, so refresh/reopen the transaction thread
5. Right-click or long-press the hold/unhold system message
6. Choose Reply in thread
7. Verify the thread title for hold system message is "held this expense"
8. Verify the thread title for unhold system message is "unheld this expense"

Do we agree 👍 or 👎

@neil-marcellini
Copy link
Contributor

I don't think we really need a regression test for this one, at least not until we fix the backend bug you mentioned.

@melvin-bot melvin-bot bot added the Overdue label May 24, 2024
@miljakljajic
Copy link
Contributor

Payment summary: @Ollyws is owed 500 USD for their work on this issue

@melvin-bot melvin-bot bot removed the Overdue label May 27, 2024
@miljakljajic
Copy link
Contributor

Bernard has been paid

@Ollyws
Copy link
Contributor

Ollyws commented May 27, 2024

Payment summary: @Ollyws is owed 500 USD for their work on this issue

@miljakljajic Was this one a $500 not $250?

@JmillsExpensify
Copy link

Reached out to Milja via DM to confirm.

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 Internal Requires API changes or must be handled by Expensify staff
Projects
Status: Done
Development

No branches or pull requests

7 participants