Dynamically add or remove entities from a geojson datasource. Please help!

Hi all,
I am stuck trying to filter features in a geojson based on features’ id and a text input field. I can display all the entities in the datasource, do the show=true/false for the entire geojson, but I cannot get my head around how to efficiently show only the entities based on condition.

Since I have two variables - a js object that reduces or increases based on user input, and a datasource with a feature collection, I assume a nested loop should do the job but it does not:

const entities = viewer.dataSources.getByName(dataSourceName)[0].entities.values;

for (let i = 0; i < entities.length; i++) {
	for(let ii = 0; ii < $filtered_features.features.length; ii++){
		if($filtered_features.features[ii].properties.item_id === entities[i].properties.item_id._value) {
			entities[i].show = true; //console.log("SHOW THIS ENTITY!")
		} else {
			entities[i].show = false; //console.log("HIDE THIS ENTITY!")
		}
	}
}

I am picking up the property ‘item_id’ to do the check between the user-filtered list and the actual features that need to be dynamically shown/hidden from the geojson in viewer. The issue is that I cannot visualize correctly the filtered entities based on the user input field.
Any heads up?