Generate task after a certain condition from the app form

You are still not using appliesIf as suggested above.

You might want to build your task configuration like this:

module.exports = [
  {
    name: 'FLHW Follow-Up Task',
    title: 'task.follow_up',
    appliesTo: 'reports',
    appliesToType: ['screening_form'],
    actions: [{ form: 'follow_up' }],
    events: [
      {
        id: 'hypertension-followup-1',
        days: 3,
        start: 2,
        end: 2,
      },
      {
        id: 'hypertension-followup-2',
        days: 14,
        start: 2,
        end: 2,
      },
    ],

    appliesIf: function (contact, report) {
      const isFCHVUser = cht.v1.hasPermissions(['can_view_tasks_group']);
      return isFCHVUser && Utils.getField(report, 'hypertension_screening.bp1_eq_bp2') === 'yes';
    }
  },
];

Apart from adding appliesIf, I have made other changes to your code:

  1. Identify whether the user is an FCHV by checking the permissions instead of contact.roles. Here, contact represents the patient contact, not the user. When using hasPermissions, please select the permission that is only given to the FCHV role. You can also define custom permissions in your app settings.
  2. Using Utils.getField() instead of accessing the report fields directly.
  3. Removing resolvedIf: Your task configuration should work fine without explicit resolvedIf because of the default resolvedIf behavior. This is optional.