Skip to content

[HOLD for payment 2023-08-17] [$1000] Replies count doesn't update on a task shared in group. #23920

Closed

Description

@kavimuru

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. Create a task
  2. Select a assignee
  3. Select a group to share
  4. Go to the group and update the task using checkbox (replies count updates)
  5. Go to assignee report and update the task using checkbox (replies count doesn't updates)

Expected Result:

The replies count should update in both the group and assignee report.

Actual Result:

The replies count updates in the group but not in assignee report.

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Platforms:

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

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.47-2
Reproducible in staging?: y
Reproducible in production?: y
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
Notes/Photos/Videos: Any additional supporting documentation

task_replies_bug_demo.mp4
Recording.1409.mp4

Expensify/Expensify Issue URL:
Issue reported by: @Krishna2323
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1690705764414639

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~013bbb12e93147362e
  • Upwork Job ID: 1686236770866049024
  • Last Price Increase: 2023-08-01
  • Automatic offers:
    • s77rt | Reviewer | 25923313
    • s-alves10 | Contributor | 25923314

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 31, 2023
  2. melvin-bot commented on Jul 31, 2023

    @melvin-bot

    Triggered auto assignment to @JmillsExpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

  3. melvin-bot commented on Jul 31, 2023

    @melvin-bot

    Bug0 Triage Checklist (Main S/O)

    • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
    • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
      • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
    • This bug is reproducible using the reproduction steps in the OP. S/O
      • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
      • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
    • This issue is filled out as thoroughly and clearly as possible
      • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
    • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync
  4. yh-0218 commented on Aug 1, 2023

    @yh-0218
    Contributor

    Proposal

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

    Replies count doesn't update on a task shared in group.

    What is the root cause of that problem?

    When we complete or reopen task, we are calling completeTask and reopenTask of Task.js
    In these function, we are increasing childVisibleActionCount of action.
    In the reopen case:

    const optimisticParentReportData = ReportUtils.getOptimisticDataForParentReportAction(taskReportID, reopenedTaskReportAction.created, CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD);

    App/src/libs/ReportUtils.js

    Lines 1528 to 1543 in 3324ea7

    const getOptimisticDataForParentReportAction = (reportID, lastVisibleActionCreated, type) => {
    const report = getReport(reportID);
    if (report && report.parentReportActionID) {
    const parentReportAction = ReportActionsUtils.getParentReportAction(report);
    if (parentReportAction && parentReportAction.reportActionID) {
    return {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`,
    value: {
    [parentReportAction.reportActionID]: updateOptimisticParentReportAction(parentReportAction, lastVisibleActionCreated, type),
    },
    };
    }
    }
    return {};
    };

    To update childVisibleActionCount of action, we got parentReportAction from task.
    This is only action of shared channel.
    so only shared channel reply is increased and direct channel reply is not increased(only updated after refresh)

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

    We need to childVisibleActionCount of 2 actions(shared channels action and direct channel action).
    In my test case, actions ids are 6032435466773608246 and 6281777622256522668.
    We can send this as parameter to update.

    What alternative solutions did you explore? (Optional)

    We can get origin 2 actions on update function.

  5. JmillsExpensify commented on Aug 1, 2023

    @JmillsExpensify
    Contributor

    Hmmm, I agree that minimally we should be treating the history reportAction the same for the room and DM cases. I'll triage.

  6. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Aug 1, 2023
  7. changed the title [-]Replies count doesn't update on a task shared in group.[/-] [+][$1000] Replies count doesn't update on a task shared in group.[/+] on Aug 1, 2023
  8. melvin-bot commented on Aug 1, 2023

    @melvin-bot
  9. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Aug 1, 2023
  10. melvin-bot commented on Aug 1, 2023

    @melvin-bot

    Current assignee @JmillsExpensify is eligible for the External assigner, not assigning anyone new.

  11. melvin-bot commented on Aug 1, 2023

    @melvin-bot

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

  12. dummy-1111 commented on Aug 1, 2023

    @dummy-1111
    Contributor

    Proposal

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

    Replies count doesn't update on a task shared in group when we update the task in assignee report

    What is the root cause of that problem?

    When we create a task, we set the parentReportID of the newly created task report to the shareDestination reportID

    setParentReport(lodashGet(props.reports, `report_${props.task.shareDestination}`, {}));

    And we create the new comment in shareDestination report and set the parentReportActionID of the task to the reportActionID of the new comment

    const optimisticAddCommentReport = ReportUtils.buildOptimisticTaskCommentReportAction(taskReportID, title, assignee, assigneeAccountID, `Created a task: ${title}`, parentReportID);
    optimisticTaskReport.parentReportActionID = optimisticAddCommentReport.reportAction.reportActionID;

    When we update(reopen or complete) a task using the checkbox, reopenTask/completeTask function in Task.js are called.

    Let's take a look at the completeTask function here
    After we set optimistic data for the task report and actions, we create the optimistic data for parent report action

    const optimisticParentReportData = ReportUtils.getOptimisticDataForParentReportAction(taskReportID, completedTaskReportAction.created, CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD);

    If we update the task in shareDestination report, all works fine because parentReportAction is updated as well here.
    But this is not the case when we update the task in assignee report. The current action of the assignee report isn't updated.

    This is the root cause

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

    We should update the assignee parent action when we update the task in assignee report. It would be better if we can update two parent actions(one in shareDestination and one in assignee, of course, when they are different)

    Solution 1

    1. Pass the additional parameters to the reopenTask/completeTask functions: reportID, reportActionID in TaskPreview

    If the current action is assignee task action,

            const isAssigneeTaskAction = props.taskReport.parentReportActionID !== props.action.reportActionID;
            const reportID = isAssigneeTaskAction ? props.reportID : undefined;
            const reportActionID = isAssigneeTaskAction ? props.action.reportActionID : undefined;
    
            onPress={() => {
                if (isTaskCompleted) {
                    Task.reopenTask(props.taskReportID, taskTitle, reportID, reportActionID);
                } else {
                    Task.completeTask(props.taskReportID, taskTitle, reportID, reportActionID);
                }
            }}
    

    Add reportID props to the TaskPreview component in ReportActionItem

            reportID={props.report.reportID}
    
    1. Add the new parameters reportID and reportActionID
        function completeTask(taskReportID, taskTitle, reportID, reportActionID)
        ...
    
        function reopenTask(taskReportID, taskTitle, reportID, reportActionID)
    

    If reportID or reportActionID are undefined, do nothing

    If not, create the optimistic data same as optimisticParentReportData created here except reportID and reportActionID

        const optimisticParentReportData = ReportUtils.getOptimisticDataForParentReportAction(taskReportID, completedTaskReportAction.created, CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD);
        if (!_.isEmpty(optimisticParentReportData)) {
            optimisticData.push(optimisticParentReportData);
            if (reportID && reportActionID) {
                const optimisticDataForAssigneeReportAction = {
                    onyxMethod: Onyx.METHOD.MERGE,
                    key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
                    value: {
                        [reportActionID]: _.values(optimisticParentReportData.value)[0],
                    },
                }
                optimisticData.push(optimisticDataForAssigneeReportAction);
            }
        }
    

    Solution 2

    We can always create the optmistic data for two parent report actions(in assignee and shareDestination report) as follows

    1. Add the following line to the buildOptimisticTaskCommentReportAction
        reportAction.reportAction.participantAccountIDs = [taskAssigneeAccountID];
    

    The backend returns this data. This is for offline mode

    1. Pass taskReport instead of taskReportID to reopenTask/completeTask in TaskPreview and TaskView

    2. Add the utility function getParentReportActionForTask in REportActionsUtils.js

    function getParentReportActionForTask(taskReportID, reportID) {
        return _.find(
            allReportActions[reportID],
            (reportAction) => reportAction && `${reportAction.childReportID}` === `${taskReportID}` && reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT,
        );
    }
    

    This is the function to find the reportAction with childReportID = taskReportID in reportActions of report(reportID)

    1. Update the reopenTask/completeTask function as follows
    • Rename the first argument from taskReportID to taskReport and add the first line
        const taskReportID = taskReport.reportID;
    
    • We can get reportID and reportActionID of the parent action of the task in assignee report.
        const assigneeChatReportID = lodashGet(ReportUtils.getChatByParticipants(taskReport.participantAccountIDs), 'reportID');
        const parentReportAction = ReportActionsUtils.getParentReportActionForTask(taskReportID, assigneeChatReportID);
    

    Now that we get reportID and reportActionID, we can create optmisticData from them as solution 1.

    The entire code would look like

        // Update optimistic data for parent report action
        const optimisticParentReportData = ReportUtils.getOptimisticDataForParentReportAction(taskReportID, completedTaskReportAction.created, CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD);
        if (!_.isEmpty(optimisticParentReportData)) {
            optimisticData.push(optimisticParentReportData);
            const assigneeChatReportID = lodashGet(ReportUtils.getChatByParticipants(taskReport.participantAccountIDs), 'reportID');
            if (assigneeChatReportID && `${assigneeChatReportID}` !== `${taskReport.parentReportID}`) {
                const parentReportAction = ReportActionsUtils.getParentReportActionForTask(taskReportID, assigneeChatReportID);
                if (parentReportAction) {
                    optimisticData.push({
                        onyxMethod: Onyx.METHOD.MERGE,
                        key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${assigneeChatReportID}`,
                        value: {
                            [parentReportAction.reportActionID]: _.values(optimisticParentReportData.value)[0],
                        },
                    });
                    failureData.push({
                        onyxMethod: Onyx.METHOD.MERGE,
                        key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${assigneeChatReportID}`,
                        value: {
                            [parentReportAction.reportActionID]: {
                                errors: ErrorUtils.getMicroSecondOnyxError('task.messages.error'),
                            },
                        },
                    });
                }
            }
        }
    

    These solutions works well. I prefer the 2nd solution

    Result
    23920.mp4

    What alternative solutions did you explore? (Optional)

    We can consider the multiple parentReportID and parentReportActionID. In this case, I think the backend should be updated as well

  13. 39 remaining items

  14. Krishna2323 commented on Sep 5, 2023

    @Krishna2323
    Contributor

    @JmillsExpensify, can you pls provide update for payments here. Thanks

  15. techievivek commented on Sep 11, 2023

    @techievivek
    Contributor

    Not overdue, I have just DMed Jason to finish the payment here. Sorry for the delay.

  16. JmillsExpensify commented on Sep 13, 2023

    @JmillsExpensify
    Contributor

    Sorry ya'll, I'm not coming back to this issue for payments/summary.

  17. JmillsExpensify commented on Sep 13, 2023

    @JmillsExpensify
    Contributor

    Payment summary:

    • Issue reporter: @Krishna2323 $250 (pre-September 1)
    • Contributor: @s-alves10 $1,500 (incl. urgency bonus)
    • Contributor+: @s77rt $1,500 (incl. urgency bonus)

    @Krishna2323 I believe you applied to the Upwork but for the wrong amount. @s-alves10 and @s77rt offers just sent.

  18. Krishna2323 commented on Sep 13, 2023

    @Krishna2323
    Contributor

    @JmillsExpensify ohh sorry, how can I apply now?
    I updated the job terms.

  19. JmillsExpensify commented on Sep 13, 2023

    @JmillsExpensify
    Contributor

    Just hired you.

  20. Krishna2323 commented on Sep 13, 2023

    @Krishna2323
    Contributor

    @JmillsExpensify, accepted.

  21. JmillsExpensify commented on Sep 13, 2023

    @JmillsExpensify
    Contributor

    Paid

  22. Krishna2323 commented on Sep 13, 2023

    @Krishna2323
    Contributor

    Thanks ✌🏻

  23. dummy-1111 commented on Sep 13, 2023

    @dummy-1111
    Contributor
  24. s77rt commented on Sep 13, 2023

    @s77rt
    Member

    @JmillsExpensify Accepted! Thanks!

  25. JmillsExpensify commented on Sep 15, 2023

    @JmillsExpensify
    Contributor

    Everyone should be paid out at this point! Closing.

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 productionBugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorWeeklyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions