Help with script: number of overdue tasks?


Hello! Sorry if this is a very basic topic but I don’t know much about applescript.

Im trying to obtain the number of overdue tasks with applescript with this:

tell application "OmniFocus"
tell front document
	-- Get the list of tasks
	set thePastTasks1 to every flattened task where its completed = false and due date is less than (current date)
	set PastCount1 to count of thePastTasks1
	if thePastTasks1 is not equal to {} then
		set reportText1 to " ☹︎ Past: " & PastCount1
		return reportText1
	end if
end tell -- end tell front document
end tell -- end tell application "OmniFocus"

But no matter what I try I never obtain the same value of overdue that the iOS app shows in the “Badges Menu”

Can someone tell me what am I doing wrong?

Thanks in advance!