The idleTimeout is basically a value that determines how long a flow in a switch will last if it doesn't match any traffic. So if I have a flow in a switch with an idleTimeout of 5 seconds that matches all ICMP traffic on a given switch port, then as long as ICMP traffic is entering that switch port, that flow will continue to exist. If no ICMP traffic goes through the switch port for 5 seconds, the flow will timeout, and it will be removed from the switch. In short Idle timeout is a absolute timeout in which if there are no packets hitting the flow for the duration, then flow is removed from the device.
The hardTimeout, on the other hand, is a hard limit on how long a given flow can exist in the switch. If I have a flow in a switch with a hardTimeout of 5 seconds that matches all ICMP traffic on a given switch port, then even if ICMP traffic is continuously entering the switch port, that flow will time out after 5 seconds and it will be removed from the switch. In short Hard timeout is absolute timeout after which the flow is removed from the device.
Ref:
https://www.opennetworking.org/images/stories/downloads/sdn-resources/onf-specifications/openflow/openflow-spec-v1.0.0.pdf