Removes purchases that are missing from the new purchases array and match the given predicate.

@param {array} existingPurchases - an array of purchases in the store
@param {array} newPurchases - an array of purchases fetched from the API
@param {object} predicate - the predicate to check before removing the item from the array.
@return {array} An array of purchases
function removeMissingPurchasesByPredicate( existingPurchases, newPurchases, predicate ) {
	return existingPurchases.filter( purchase => {
		if ( matches( predicate )( purchase ) && find( newPurchases, { ID: purchase.ID } ) ) {
			// this purchase is present in the new array
			return true;
		}

		if ( ! matches( predicate )( purchase ) ) {
			// only overwrite remove purchases that match the predicate
			return true;
		}

		// the purchase doesn't match the predicate or is missing from the array of new purchases
		return false;
	} );
}