Skip to content

Commit c671974

Browse files
committed
Rollback removeNestedNullValues refactor
1 parent 79b018d commit c671974

1 file changed

Lines changed: 6 additions & 26 deletions

File tree

lib/utils.ts

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -172,34 +172,14 @@ function isMergeableObject<TObject extends Record<string, unknown>>(value: unkno
172172

173173
/** Deep removes the nested null values from the given value. */
174174
function removeNestedNullValues<TValue extends OnyxInput<OnyxKey> | null>(value: TValue): TValue {
175-
if (value === null || value === undefined) {
176-
return value;
175+
if (typeof value === 'object' && !Array.isArray(value)) {
176+
return fastMerge(value, value, {
177+
shouldRemoveNestedNulls: true,
178+
objectRemovalMode: 'replace',
179+
}).result;
177180
}
178181

179-
if (typeof value !== 'object' || Array.isArray(value)) {
180-
return value;
181-
}
182-
183-
const result: Record<string, unknown> = {};
184-
185-
// eslint-disable-next-line no-restricted-syntax, guard-for-in
186-
for (const key in value) {
187-
const propertyValue = value[key];
188-
189-
if (propertyValue === null || propertyValue === undefined) {
190-
// eslint-disable-next-line no-continue
191-
continue;
192-
}
193-
194-
if (typeof propertyValue === 'object' && !Array.isArray(propertyValue)) {
195-
const valueWithoutNestedNulls = removeNestedNullValues(propertyValue);
196-
result[key] = valueWithoutNestedNulls;
197-
} else {
198-
result[key] = propertyValue;
199-
}
200-
}
201-
202-
return result as TValue;
182+
return value;
203183
}
204184

205185
/** Formats the action name by uppercasing and adding the key if provided. */

0 commit comments

Comments
 (0)