docs: def _tasks_to_reinsert(tasks, transactional):
      """Return a list containing the tasks that should be reinserted based on the
      was_enqueued property and whether the insert is transactional or not.
      """
      if transactional:
          return tasks
  
      return [task for task in tasks if not task.was_enqueued]