Indraneel | #1205 | SEARCH accounting prod issue - fixing query to handle edge cases