[SalesForce] What fields determine what is displayed in Open Activities vs. Activity History

What determines which tasks go into the boxes Open Activities and Activity history, respectively?
I tried the fields Status, IsArchived, IsClosed, but none of them relate the image I see in my single Account page.

Best Answer

For Task records, the differentiation is based on Status. You can query for all closed values as follows:

Set<String> closedStatuses = new Set<String>();
for(TaskStatus status: [SELECT MasterLabel FROM TaskStatus WHERE IsClosed = true])
    closedStatuses.add(status.MasterLabel);

For Event records, the differentiation is based solely on the StartDateTime field. If it is in the past, it is history. If it is in the future, it is open.