[FIX][EE] Agent cannot change status to Available despite being within open business hours #24112
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes (including videos or screenshots)
Issue(s)
Steps to test or reproduce
Expected Behavior:
The agent should be able to change it back to Available as long as the business hour for the default department is active.
Actual Behavior:
Even with the business hours still open, the agent is unable to change Omnichannel status back to Available as they keep getting the error message "Business hours are closed". The error in the server log is:
server.js:204 System ➔ error Exception while invoking method livechat:changeLivechatStatus Not allowed [error-business-hours-are-closed]Further comments
Sidenote from Tech point of view: There were a lot of scenarios where the business hour might throw false negatives - the one I mentioned above. This is a result of a stale business hour cache that we maintain on the user's DB collection. My first thought was to handle all the edge cases which were causing this stale cache issue, but after a few minutes, I realised there can be a lot of these cases, so instead of complicating the implementation by handling each of the above cases, I went with a different approach.
What I do now instead is, if no active business hour is found within the user's cache, then we recheck if any business hour is active at the time being for this agent.
I do understand with this new implementation, there would be more processing required for true negatives, but I think that's a fair tradeoff to avoid false negatives like this since those are affecting the end-users