Function not working properly after update

Hello folks,

The function below was working normally, but after some n8n updates it stopped working as it should.
What it does is get a value from a previous node and check if this value is the same, if so it should return the string “Mesmo Motorista” but it is not returning that value anymore. It keeps returning the same value in an array.
Nothing has changed in this function.

const new_items = [];
// Get static data stored with the workflow
const data = this.getWorkflowStaticData("node");
data.placaatual = data.placaatual || [];
for (var i = items.length - 1; i >= 0; i--) {
// Check if data is already present
  if (data.placaatual.includes(items[i].json.placaatual)) {
  } else {
// if new data then add it to an array
      json: {
        placaatual: items[i].json.placaatual,
data.placaatual = => item.json.placaatual);
// Check if array is empty
if (new_items.length === 0) {
  return [{ json: { placaatual: "Mesmo Motorista" } }];
} else {
// return new items if array is not empty
  return new_items;

Hey @mtcoliveira, I am sorry to hear you’re having trouble.

Could you narrow down what exactly is failing for you here? It sounds like your new_items.length value could always equals 0 for you, but it’s hard to say without knowing your actual data.