mysql – Using subquery within the IF condition

Hi, I am having a strange problem, I currently have the following query

SELECT *
FROM `txt_campaign_message` `cm`
         LEFT JOIN `txt_campaign` `c` ON c.id = cm.campaign_id
         LEFT JOIN `txt_message` `m` ON m.id = cm.message_id
         LEFT JOIN `txt_campaign_subscriber` `cs` ON cs.campaign_id = cm.campaign_id
WHERE ((`c`.`user_id` = 2) AND (`m`.`message_type` = 'blast') AND (`c`.`active` = 1))
  AND (NOT (`cs`.`subscriber_id` IS NULL))
  AND cs.subscriber_id = (
    (IF
        (cm.date_range_from IS NOT NULL,
         (SELECT cs1.subscriber_id
           from `txt_campaign_subscriber` cs1
           WHERE DATE(cs.created_at) BETWEEN DATE(cm.date_range_from) AND DATE(cm.date_range_to)
         ),
         (cs.subscriber_id)
        )
    )
  )
  AND (`cm`.`campaign_id` = 1386)

which gave me an error

The subquery returns several rows

and I changed the query part AND cs.subscriber_id = (IF use IN rather than = before the condition as below

SELECT *
FROM `txt_campaign_message` `cm`
         LEFT JOIN `txt_campaign` `c` ON c.id = cm.campaign_id
         LEFT JOIN `txt_message` `m` ON m.id = cm.message_id
         LEFT JOIN `txt_campaign_subscriber` `cs` ON cs.campaign_id = cm.campaign_id
WHERE ((`c`.`user_id` = 2) AND (`m`.`message_type` = 'blast') AND (`c`.`active` = 1))
  AND (NOT (`cs`.`subscriber_id` IS NULL))
  AND cs.subscriber_id IN (
    (IF
        (cm.date_range_from IS NOT NULL,
         (SELECT cs1.subscriber_id
           from `txt_campaign_subscriber` cs1
           WHERE DATE(cs.created_at) BETWEEN DATE(cm.date_range_from) AND DATE(cm.date_range_to)
         ),
         (cs.subscriber_id)
        )
    )
  )
  AND (`cm`.`campaign_id` = 1386)

But the error remains the same, to my surprise if I delete the if condition and only use the subquery, everything works fine

SELECT *
FROM `txt_campaign_message` `cm`
         LEFT JOIN `txt_campaign` `c` ON c.id = cm.campaign_id
         LEFT JOIN `txt_message` `m` ON m.id = cm.message_id
         LEFT JOIN `txt_campaign_subscriber` `cs` ON cs.campaign_id = cm.campaign_id
WHERE ((`c`.`user_id` = 2) AND (`m`.`message_type` = 'blast') AND (`c`.`active` = 1))
  AND (NOT (`cs`.`subscriber_id` IS NULL))
  AND cs.subscriber_id IN (
         (SELECT cs1.subscriber_id
           from `txt_campaign_subscriber` cs1
           WHERE DATE(cs.created_at) BETWEEN DATE(cm.date_range_from) AND DATE(cm.date_range_to)
         )
  )
  AND (`cm`.`campaign_id` = 1386)

and when I add the condition again, it starts to throw the same error, what am I doing wrong or what do I need to change if I am using the IF condition for the subquery? I already changed = to IN As I needed several rows to compare.

I'm using MariaDB (10.3) where am I facing the problem