Unflag Available Tasks?

That script that I posted that ChapGPT helped refine works for the most part, but blocked tasks that would be available were they not blocked are also unflagged by it, which is not desired. Nothing I can get ChatGPT to do about this seems to work either.

If you have any other ideas, I’d welcome and update to your script to try.

I couldn’t get earlier to this, since I had some issues, but I will come back.

Those tasks had a defer date, right ? Otherwise, that is not possible, I think. Could you check ?

These aren’t valid constructors in OF API.

This should do it:

(() => {
    const
        tasks = flattenedTasks.filter(
            x => [
                Task.Status.Next,
                Task.Status.Available,
                Task.Status.DueSoon,
                Task.Status.Overdue
            ].some(y => x.taskStatus === y && x.flagged)
        );

    return (
        // tasks.forEach(x => x.flagged = false),
        tasks
    )
})();

Here’s what console gives me when I enter what you just posted. (I’ve truncated some of the task names so as not to display things I’d rather not.)

[[object Task: Clean out my car], [object Task: Buy Mother’s Day cards], [object Task: Print eye exam receipt], [object Task: Taxes], [object Task: Workshop a monthly payment workflow], [object Task: Enter Saturday, 4/15’s Notes], [object Task: Run shortcut to generate tasks for any missed visits* (schedule appts first)], [object Task: Claims: Enter any missed visit stuff into SP], [object Task: Claims: Process any “Unpaid” or “Partially Paid” claims, and “Awaiting Payment” invoices], [object Task: Use ‘Report’ shortcut to log a projection for income, update financial sheet], …] (19) = $1

And it’s weird, it’s tasks that have a due date, except there are a few others that remain flagged despite not having a due date. Some of these also have defer dates and some do not. I don’t see any obvious commonalities between them. At this point I’m more perplexed by it than anything.

Also, I had ChatGPT update the script I posted here to also filter out blocked tasks, which I say here in the interest of a complete list of factors I attempted to block for lack of being able to specify “Available” and have that work right.

Oh, and I missed that you commented out a line again. When I remove the comment part of it, it DOES WORK. I gotta run for now but I’ll test it later to make sure if does and doesn’t affect the right sorts of tasks, but that’s great. Heh.

So this appears to work within the console, but I can’t seem to paste it in the right way or modify it in the right way to work as a plug-in.