App: [HOLD for payment] [$250] BUG: Prevent editing messages sent to Chronos

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Send any message to chronos
  2. Edit message sent to chronos
  3. See Auth UpdateReportComment returned an error
  4. Notice that the edits were not recognized, either

Expected Result:

User should not be to initiate editing messages sent to Chronos

Actual Result:

User is able to try to edit their message. An error message Auth UpdateReportComment is surfaced and the edit wasn’t recognized. A red dot is also shown besides chronos in the LHN.

Workaround:

Sign out and sign back in to clear the error red dot.

Platform:

Where is this issue occurring?

  • All platforms

Version Number: 1.2.12-2 Reproducible in staging?: y Reproducible in production?: y Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos:

https://user-images.githubusercontent.com/43996225/194736175-6f4bcf82-5fcb-4350-8d28-e892a7e235ca.mp4

image (1)

Expensify/Expensify Issue URL: Issue reported by: @michaelhaxhiu Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1665171071433639

View all open jobs on GitHub

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 45 (36 by maintainers)

Most upvoted comments

@jayeshmangwani Your proposal looks good to me. Few suggestions:

@jayeshmangwani’s Proposal looks good to me.

🎀👀🎀 C+ reviewed

cc: @roryabraham

@jayeshmangwani / @roryabraham can you please complete the steps here?

@tjferriss Applied. This is eligible for 50% bonus as well.

@tjferriss Applied for the job

Thanks for the reminder. It looks like the job post expired. I just set up a new one here - https://www.upwork.com/jobs/~0162b815998a19498c.

@jayeshmangwani and @sobitneupane can you both please apply? Let me know when you do here and I’ll process payment promptly.

Ok I’m manually adding the checklist to close this out:

@tjferriss The proposal is not accepted by CME yet. Waiting approval from @roryabraham.

Proposal

  1. we have to create a new function that can check if the report object has any participants with CHRONOS mail in src/libs/ReportUtils.js file file
+/**
+ * Returns true if Chronos is one of the chat participants (1:1)
+ * @param {Object} report
+ * @returns {Boolean}
+ */
+function chatIncludesChronos(report) {
+    return report.participants
+            && _.contains(report.participants, CONST.EMAIL.CHRONOS);
+}
  1. we have to pass a new param with like this
<MiniReportActionContextMenu
    reportID={this.props.report.reportID}
    reportAction={this.props.action}
    isArchivedRoom={ReportUtils.isArchivedRoom(this.props.report)}
    displayAsGroup={this.props.displayAsGroup}
    isVisible={
        hovered
        && !this.state.isContextMenuActive
        && !this.props.draftMessage
    }
    draftMessage={this.props.draftMessage}
+  isChronosRoom={ReportUtils.chatIncludesChronos(this.props.report)}
/>
  1. we have to pass new param to the contextAction.shouldShow function

https://github.com/Expensify/App/blob/e434efa1c455620c510441628b94081e0f8a564e/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js#L40

-const shouldShowFilter = contextAction => contextAction.shouldShow(this.props.type, this.props.reportAction, this.props.isArchivedRoom, this.props.betas, this.props.anchor);
+const shouldShowFilter = contextAction => contextAction.shouldShow(this.props.type, this.props.reportAction, this.props.isArchivedRoom, this.props.betas, this.props.anchor, this.props.isChronosRoom);
  1. we have to add an one more condition that if chat is not the chronos then shouldShow will be true

https://github.com/Expensify/App/blob/e434efa1c455620c510441628b94081e0f8a564e/src/pages/home/report/ContextMenu/ContextMenuActions.js#L165-L167

-shouldShow: (type, reportAction, isArchivedRoom) => (
-    type === CONTEXT_MENU_TYPES.REPORT_ACTION && ReportUtils.canEditReportAction(reportAction) && !isArchivedRoom
-),
+shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosRoom) => (
+    type === CONTEXT_MENU_TYPES.REPORT_ACTION && ReportUtils.canEditReportAction(reportAction) && !isArchivedRoom && !isChronosRoom
+),

video after fix

https://user-images.githubusercontent.com/35371050/199975543-466a70c0-c55b-4193-b11e-1d8b3aa26363.mov

Based on slack discussion let’s mark this as external and it should assign a BZ to post to upwork.

We think the job value should be capped at $500 since this is straightforward/easy (but start price at $250). That’s the gist from slack post. 🚀

Sounds good, thanks for posting @michaelhaxhiu!

Posted here in #expensify-open-source.

Was thinking a quick post in #expensify-open-source? If we #donothing then this bug will persist anytime someone tries to edit messages to chronos. I feel like we should prevent editing the messages there for that reason.

@NikkiWines that’s a great philosophical question. I agree with your logic and reasoning. I bet we can just coin a rule here… anytime you talk to a bot, you can’t change your messages.