def METHOD_NAME(fix, activity_gateway: IActivityGateway, **_):
    """Check activities have correct start/end/delete dates.
    Args:
        fix(bool): Whether to fix found issues.
        activity_gateway(IActivityGateway): Injected ActivityGateway.
        _: keyword arguments.
    Returns:
        Tuple[bool, Optional[str]]: Tuple of whether there are activities with invalid dates, if they can be
            automatically fixed and a string of the problem.
    """
    invalid_activities = []
    for activity in activity_gateway.get_all_activities(include_deleted=True):
        plan = activity.association.plan
        if (
            activity.started_at_time < plan.date_created
            or activity.ended_at_time < activity.started_at_time
            or (activity.invalidated_at and activity.invalidated_at < activity.ended_at_time)
        ):
            invalid_activities.append(activity)
    if not invalid_activities:
        return True, False, None
    if not fix:
        ids = [a.id for a in invalid_activities]
        message = (
            WARNING
            + "The following activity have incorrect start, end, or delete date (use 'renku doctor --fix' to fix them):"
            + "\n\t"
            + "\n\t".join(ids)
        )
        return False, True, message
    fix_activity_dates(activities=invalid_activities)
    project_context.database.commit()
    communication.info("Activity dates were fixed")
    return True, False, None