Old completed task are reappearing

Hi everyone,

We’re reaching out to the community for some assistance with anissue in our stock management workflow. We’re observing tasks that were completed around October/November reappearing for users.

With our current purging, when the tasks has reappeared, both the report that initially triggered it and the report that resolved it should be purged. However, despite this, the tasks are still surfacing.

After analyzing the task data, we’ve noticed that the initial event of these reappearing tasks has an enddate set far in the future. We’re wondering if this extended enddate could be the underlying cause of these reappearing tasks.

To clarify, users have already completed these tasks once, and now, upon reappearance, they’re completing them again.

Has anyone encountered a similar issue, or does anyone have insights into how a future enddate might be affecting task reappearance or other reason to explain this? Any suggestions or troubleshooting tips would be greatly appreciated.


the full task docs

{
  "_id": "task~org.couchdb.user:inkonate~44ae45b4-a6c1-48a7-a762-fa7fd536295e~0~task.smw.distribution~1738241472645",
  "_rev": "2-ce99928187eb6c1bd0a7154cdfaf69b5",
  "type": "task",
  "authoredOn": 1738241472645,
  "stateHistory": [
    {
      "state": "Ready",
      "timestamp": 1738241472645
    },
    {
      "state": "Completed",
      "timestamp": 1738241727268
    }
  ],
  "user": "org.couchdb.user:inkonate",
  "requester": "b1100d0b-26a8-4b87-a5a0-efa6d16c1f19",
  "owner": "b1100d0b-26a8-4b87-a5a0-efa6d16c1f19",
  "emission": {
    "_id": "44ae45b4-a6c1-48a7-a762-fa7fd536295e~0~task.smw.distribution",
    "title": "smw.distribution.tasks",
    "icon": "icon-healthcare-medicine",
    "deleted": false,
    "resolved": true,
    "actions": [
      {
        "type": "report",
        "form": "stock_receipt",
        "label": "Follow up",
        "content": {
          "source": "task",
          "source_id": "44ae45b4-a6c1-48a7-a762-fa7fd536295e",
          "t_enriched_flour_qty": "",
          "t_iron_folic_acid_qty": "",
          "t_amoxicillin_250_tablet_qty": "",
          "t_amoxicillin_250_syrup_qty": "",
          "t_al_20120_qty": "120",
          "t_asaq_2_11m_qty": "",
          "t_asaq_1_5y_qty": "",
          "t_asaq_6_13y_qty": "",
          "t_asaq_14yplus_qty": "",
          "t_malaria_rdt_qty": "25",
          "t_artesunate_50_qty": "",
          "t_artesunate_100_qty": "",
          "t_artesunate_200_qty": "",
          "t_arthemeter_40_qty": "",
          "t_paracetamol_500_qty": "",
          "t_paracetamol_250_disp_qty": "",
          "t_paracetamol_100_disp_qty": "",
          "t_zinc_20_qty": "",
          "t_ors_qty": "",
          "t_pregnancy_rdt_qty": "",
          "t_sayana_press_qty": "",
          "t_male_condom_qty": "",
          "t_female_condom_qty": "",
          "t_cycle_collar_qty": "",
          "t_depo_provera_qty": "",
          "t_postpill_qty": "",
          "t_simple_pill_qty": "",
          "t_low_dose_pill_qty": "",
          "t_cscom_area": "",
          "t_supplier_id": "b8f8adab-7648-492f-9a14-7ea08a6d811e",
          "t_supplier_name": "SUP-FANNY KASSOUM",
          "t_supplier_place_name": "Z.S.MAD 04",
          "t_is_distribution": "true",
          "t_distribution_date": "2024-10-13",
          "t_task_type": "report"
        }
      }
    ],
    "contact": {
      "name": "Z.A.SEG01 04001"
    },
    "dueDate": "2024-10-13",
    "startDate": "2024-10-13",
    "endDate": "2025-10-13",
    "forId": "b1100d0b-26a8-4b87-a5a0-efa6d16c1f19"
  },
  "state": "Completed"
}

{
  "_id": "task~org.couchdb.user:inkonate~44ae45b4-a6c1-48a7-a762-fa7fd536295e~0~task.smw.distribution~1728846009799",
  "_rev": "2-7422fc076bba72163382cd903694c1df",
  "type": "task",
  "authoredOn": 1728846009799,
  "stateHistory": [
    {
      "state": "Ready",
      "timestamp": 1728846009799
    },
    {
      "state": "Completed",
      "timestamp": 1728847356184
    }
  ],
  "user": "org.couchdb.user:inkonate",
  "requester": "b1100d0b-26a8-4b87-a5a0-efa6d16c1f19",
  "owner": "b1100d0b-26a8-4b87-a5a0-efa6d16c1f19",
  "emission": {
    "_id": "44ae45b4-a6c1-48a7-a762-fa7fd536295e~0~task.smw.distribution",
    "title": "smw.distribution.tasks",
    "icon": "icon-healthcare-medicine",
    "deleted": false,
    "resolved": true,
    "actions": [
      {
        "type": "report",
        "form": "stock_receipt",
        "label": "Follow up",
        "content": {
          "source": "task",
          "source_id": "44ae45b4-a6c1-48a7-a762-fa7fd536295e",
          "t_enriched_flour_qty": "",
          "t_iron_folic_acid_qty": "",
          "t_amoxicillin_250_tablet_qty": "",
          "t_amoxicillin_250_syrup_qty": "",
          "t_al_20120_qty": "120",
          "t_asaq_2_11m_qty": "",
          "t_asaq_1_5y_qty": "",
          "t_asaq_6_13y_qty": "",
          "t_asaq_14yplus_qty": "",
          "t_malaria_rdt_qty": "25",
          "t_artesunate_50_qty": "",
          "t_artesunate_100_qty": "",
          "t_artesunate_200_qty": "",
          "t_arthemeter_40_qty": "",
          "t_paracetamol_500_qty": "",
          "t_paracetamol_250_disp_qty": "",
          "t_paracetamol_100_disp_qty": "",
          "t_zinc_20_qty": "",
          "t_ors_qty": "",
          "t_pregnancy_rdt_qty": "",
          "t_sayana_press_qty": "",
          "t_male_condom_qty": "",
          "t_female_condom_qty": "",
          "t_cycle_collar_qty": "",
          "t_depo_provera_qty": "",
          "t_postpill_qty": "",
          "t_simple_pill_qty": "",
          "t_low_dose_pill_qty": "",
          "t_cscom_area": "",
          "t_supplier_id": "b8f8adab-7648-492f-9a14-7ea08a6d811e",
          "t_supplier_name": "SUP-FANNY KASSOUM",
          "t_supplier_place_name": "Z.S.MAD 04",
          "t_is_distribution": "true",
          "t_distribution_date": "2024-10-13",
          "t_task_type": "report"
        }
      }
    ],
    "contact": {
      "name": "Z.A.SEG01 04001"
    },
    "dueDate": "2024-10-13",
    "startDate": "2024-10-13",
    "endDate": "4762-09-09",
    "forId": "b1100d0b-26a8-4b87-a5a0-efa6d16c1f19"
  },
  "state": "Completed"
}

Current code in tasks.js


 appliesIf: function (contact, report) {
      return user.parent._id === Utils.getField(report, 'place_id');
    },
    resolvedIf: function (contact, report) {
      const submittedStockCountReports = contact.reports
        .filter(rpt => Forms.SMW_STOCK_RECEIPT === rpt.form)
        .filter(rpt => Utils.getField(rpt, 'inputs.source_id') === report._id);
      return submittedStockCountReports.length > 0;
    },